17 Nov - Static Sites to laravel
This commit is contained in:
parent
610aa1e202
commit
5ff57a21a7
3661 changed files with 569001 additions and 771 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue