59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
|
|
use Dcat\Admin\Traits\ModelTree;
|
|
use EloquentFilter\Filterable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Kalnoy\Nestedset\NodeTrait;
|
|
|
|
class ProductCategory extends Model
|
|
{
|
|
use Concerns\HasShowable;
|
|
use Filterable;
|
|
use NodeTrait;
|
|
use ModelTree;
|
|
use HasDateTimeFormatter;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $attributes = [
|
|
'is_show' => false,
|
|
'is_recommend' => false,
|
|
'sort' => 0,
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'is_show' => 'boolean',
|
|
'is_recommend' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'icon',
|
|
'is_show',
|
|
'is_recommend',
|
|
'sort',
|
|
];
|
|
|
|
// 排序字段名称,默认值为 order
|
|
protected $orderColumn = 'sort';
|
|
|
|
// 标题字段名称,默认值为 title
|
|
protected $titleColumn = 'name';
|
|
|
|
public function getDefaultParentId()
|
|
{
|
|
return $this->parent_id;
|
|
}
|
|
}
|