<?php

namespace App\Http\Requests;


class StoreCourse extends Request
{
    /**
     * 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 [
            'course_id'   => 'bail|required',
            'member_name' => 'bail|required|max:30|min:1|unique:course_users,member_name',
            'member_no'   => 'bail|required|max:30|min:1|unique:course_users,member_no',
            'whs'         => 'bail|required|max:30|min:1|unique:course_users,whs',
        ];
    }

    public function messages()
    {
        return [
            'course_id.required'   => trans('api.COURSE_REQUIRED'),
            'member_name.required' => trans('api.NAME_REQUIRED'),
            'member_name.max'      => trans('api.NAME_TOO_LONG'),
            'member_name.min'      => trans('api.NAME_TOO_SHORT'),
            'member_name.unique'   => trans('api.NAME_HAD_USED'),
            'member_no.max'        => trans('api.MEMBER_LENGTH_ILLEGAL'),
            'member_no.min'        => trans('api.MEMBER_LENGTH_ILLEGAL'),
            'member_no.unique'     => trans('api.MEMBER_USED'),
            'whs.max'              => trans('api.WHS_LENGTH_ILLEGAL'),
            'whs.min'              => trans('api.WHS_LENGTH_ILLEGAL'),
            'whs.unique'           => trans('api.WHS_USED'),
            'whs.required'         => trans('api.WHS_REQUIRED'),
        ];
    }


}
