1
0
Fork 0

更新 app/Models/Keyword.php

panliang 2023-12-01 09:41:54 +08:00
parent 19ea8cfdf9
commit 9ace922048
1 changed files with 2 additions and 16 deletions

View File

@ -6,13 +6,14 @@ use App\Casts\StorageFile;
use EloquentFilter\Filterable;
use Illuminate\Database\Eloquent\Model;
use App\Traits\HasDateTimeFormatter;
use App\Traits\TreePath;
/**
* 字典表
*/
class Keyword extends Model
{
use Filterable, HasDateTimeFormatter;
use Filterable, HasDateTimeFormatter, TreePath;
protected $fillable = ['id', 'name', 'key', 'value', 'parent_id', 'path', 'sort', 'level', 'options', 'image', 'description', 'content'];
@ -20,19 +21,4 @@ class Keyword extends Model
'options' => 'array',
'image' => StorageFile::class,
];
public function parent()
{
return $this->belongsTo(static::class, 'parent_id');
}
public function children()
{
return $this->hasMany(static::class, 'parent_id');
}
public function scopeSort($q)
{
return $q->orderByDesc('sort');
}
}