活动专区
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\SystemTool\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* 首页活动专区模型
|
||||
*/
|
||||
class SysActivityModel extends Model
|
||||
{
|
||||
protected $table = 'sys_activity';
|
||||
|
||||
protected $casts = [
|
||||
'status' => 'int',
|
||||
'sort' => 'int',
|
||||
'image_id' => 'array',
|
||||
'link_type' => 'int',
|
||||
'category_id' => 'int',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'image_id',
|
||||
'link',
|
||||
'link_type',
|
||||
'category_id',
|
||||
'description',
|
||||
'status',
|
||||
'sort',
|
||||
];
|
||||
|
||||
protected $with = ['image', 'category'];
|
||||
|
||||
/**
|
||||
* 关联图片
|
||||
* @return HasOne
|
||||
*/
|
||||
public function image(): HasOne
|
||||
{
|
||||
return $this->hasOne(SysFileModel::class, 'id', 'image_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联所属分类(link_type=1 时生效)
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SysCategoryModel::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user