<?php

namespace Modules\SystemTool\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
 * 首页宫格导航模型
 */
class SysGridNavModel extends Model
{
    protected $table = 'sys_grid_nav';

    protected $casts = [
        'status' => 'int',
        'sort' => 'int',
        'image_id' => 'int',
    ];

    protected $fillable = [
        'title',
        'image_id',
        'link',
        'status',
        'sort',
    ];

    protected $with = ['image'];

    /**
     * 关联图片
     * @return HasOne
     */
    public function image(): HasOne
    {
        return $this->hasOne(SysFileModel::class, 'id', 'image_id');
    }

}
