<?php


namespace app\admin\validate;


class MenuValidate extends BaseValidate
{

     /**
      * 设置校验规则
      * @var string[]
      */
    protected $rule = [
        'id' => 'require',
        'name' => 'require|length:1,50',
        'parent_id' => 'integer|min:0',
        'type' => 'require|integer|in:1,2',
        'icon' => 'length:0,100',
        'perms' => 'length:0,100',
        'paths' => 'length:0,100',
        'component' => 'length:0,100',
        'params' => 'length:0,100',
        'sort' => 'integer|min:0',
        'is_cache' => 'integer|in:0,1',
        'status' => 'integer|in:0,1',
    ];

    /**
     * 参数描述
     * @var string[]
     */
    protected $field = [
        'id' => 'id',
        'name' => '菜单名称',
        'parent_id' => '父菜单ID',
        'type' => '菜单类型',
        'icon' => '图标',
        'perms' => '权限',
        'paths' => '路径',
        'component' => '组件',
        'params' => '参数',
        'sort' => '排序',
        'is_cache' => '是否缓存',
        'status' => '状态',
    ];

    /**
     * @notes 编辑场景
     */
    public function sceneEdit()
    {
        return $this->only(['name', 'parent_id', 'type', 'icon', 'perms', 'paths', 'component', 'params', 'sort', 'is_cache', 'status']);
    }

    public function sceneId()
    {
        return $this->only(['id']);
    }

}