TaskRequest.php 1.4 KB
<?php

namespace App\Http\Requests\Aside\Task;

use App\Helper\Arr;
use Illuminate\Foundation\Http\FormRequest;

/**
 * Class TaskRequest
 * @package App\Http\Requests\Aside\product
 * @author zbj
 * @date 2023/4/27
 */
class TaskRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'project_id' => 'required|exists:gl_project,id',
            'owner' => 'required',
            'workload' => 'integer|max:5',
            'priority' => 'integer|max:5',
            'content' => 'required',
            'attachment' => 'max:200',
            'end_at' => 'date_format:Y-m-d H:i:s',
        ];
    }

    public function messages()
    {
        return [
            'project_id.required' => '项目ID不能为空',
            'project_id.exists' => '项目不存在',
            'owner.required' => '请选择负责人',
            'workload.max' => '工作量最多5星',
            'priority.max' => '紧急程度最多5星',
            'content' => '请输入工单内容',
            'end_at.date_format' => '截止时间格式不正确',
        ];
    }

}