小程序首页配置
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Modules\SystemTool\Models\SysFileModel;
|
||||
|
||||
/**
|
||||
* 小程序首页宫格导航
|
||||
*/
|
||||
class HomeNavModel extends Model
|
||||
{
|
||||
/** 状态:停用 */
|
||||
public const int STATUS_DISABLED = 0;
|
||||
/** 状态:正常 */
|
||||
public const int STATUS_NORMAL = 1;
|
||||
|
||||
protected $table = 'mini_home_nav';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'image_id',
|
||||
'link',
|
||||
'sort',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'image_id' => 'integer',
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
'created_at' => 'datetime:Y-m-d H:i:s',
|
||||
'updated_at' => 'datetime:Y-m-d H:i:s',
|
||||
];
|
||||
|
||||
protected $appends = ['image_url'];
|
||||
|
||||
protected $with = ['image'];
|
||||
|
||||
/**
|
||||
* 关联图标
|
||||
*/
|
||||
public function image(): HasOne
|
||||
{
|
||||
return $this->hasOne(SysFileModel::class, 'id', 'image_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 图标链接
|
||||
*/
|
||||
public function getImageUrlAttribute(): ?string
|
||||
{
|
||||
return $this->image?->preview_url;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user