123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Http\Requests;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Support\Arr;
- class WorkerRequest 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()
- {
- $id = (int) optional($this->route('worker'))->id;
- $rules = [
- 'job_number'=>'required|max:6|min:3|unique:admin_users,job_number,'.$id,
- 'account'=>'required|unique:admin_users,account,'.$id,
- 'name'=>'required',
- 'phone'=>'required',
- 'area_id'=>'required',
- 'status'=>'required'
- ];
- if ($this->isMethod('put')) {
- $rules = Arr::only($rules, $this->keys());
- }
- return $rules;
- }
- public function attributes()
- {
- return [
- 'job_number' => '工号',
- 'account' => '账号',
- 'name' => '姓名',
- 'phone' => '电话',
- 'area_id' => '负责区域'
- ]; // TODO: Change the autogenerated stub
- }
- }
|