1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace App\Http\Requests;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Support\Arr;
- class ParkingRequest 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('parking'))->id;
- $rules = [
- 'name' => 'required|max:255|unique:parkings,name,'.$id,
- 'parking_fence' => 'required',
- 'area_id' => 'required',
- 'status' => 'required|boolean',
- 'max_number' => 'max:5',
- 'type' => '',
- //
- ];
- if ($this->isMethod('put')) {
- $rules = Arr::only($rules, $this->keys());
- }
- return $rules;
- }
- public function attributes()
- {
- return [
- 'name' => '区域名称',
- 'parking_fence' => '停车区域',
- 'area_id' => '所属大区',
- 'type' => '区域类型',
- 'max_number' => '最大停车数',
- 'status' => '区域状态'
- ];
- }
- }
|