<?php

namespace App\Http\Requests;

class StoreTeam 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()
    {
        $id = $this->route('id');
        return [
            'name' => 'bail|required|max:20|min:2|unique:teams,name,' . $id,
            'member_counts' => 'required',
            'desc' => 'max:100',
        ];
    }

    public function messages()
    {
        return [
            'name.required' => trans('api.NAME_REQUIRED'),
            'name.unique'   => trans('api.NAME_HAD_USED'),
            'name.max'      => trans('api.NAME_TOO_LONG'),
            'name.min'      => trans('api.NAME_TOO_SHORT'),
            'member_counts.required' => trans('api.MEMBER_COUNTS_REQUIRED'),
            'desc.max'      => trans('api.DESC_TOO_LONG'),
        ];
    }

}
