初始化项目
This commit is contained in:
38
app/Models/System/Dictionary.php
Normal file
38
app/Models/System/Dictionary.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\System;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Dictionary extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'system_dictionaries';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
'description',
|
||||
'status',
|
||||
'sort',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'status' => 'boolean',
|
||||
];
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(DictionaryItem::class, 'dictionary_id')->orderBy('sort');
|
||||
}
|
||||
|
||||
public function activeItems(): HasMany
|
||||
{
|
||||
return $this->hasMany(DictionaryItem::class, 'dictionary_id')
|
||||
->where('status', true)
|
||||
->orderBy('sort');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user