17 Nov - Static Sites to laravel

This commit is contained in:
Kevin Adametz 2018-11-17 02:01:22 +01:00
parent 610aa1e202
commit 5ff57a21a7
3661 changed files with 569001 additions and 771 deletions

View file

@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
/**
* App\Models\Category
@ -29,6 +30,8 @@ use Illuminate\Database\Eloquent\Model;
*/
class Category extends Model
{
use Sluggable;
protected $table = 'categories';
protected $casts = ['trans_name' => 'array'];
@ -37,6 +40,14 @@ class Category extends Model
'parent_id', 'name', 'pos', 'active',
];
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function parent()
{
@ -48,6 +59,12 @@ class Category extends Model
return $this->hasMany('App\Models\Category', 'parent_id', 'id');
}
public function product_categories()
{
return $this->hasMany('App\Models\ProductCategory', 'category_id', 'id');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;