123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Http\Requests;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Support\Arr;
- class BikeRequest 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('bike'))->id;
- $rules = [
- 'bike_no' => 'required|unique:bikes,bike_no,' . $id,
- 'box_no' => 'sometimes|unique:bikes,box_no,' . $id,
- 'battery_power' => '',
- 'is_link' => '',
- 'is_lock' => '',
- 'is_low_battery_power' => '',
- 'is_riding' => '',
- 'is_trouble' => '',
- 'last_use_bike_end_time' => '',
- 'last_location' => '',
- 'last_location_time' => '',
- 'put_area_id' => '',
- 'put_status' => 'required',
- 'put_time' => '',
- ];
- if ($this->isMethod('put')) {
- $rules = Arr::only($rules, $this->keys());
- }
- return $rules;
- }
- public function attributes()
- {
- return [
- 'bike_no' => '车辆编号',
- 'box_no' => '控制设备编号',
- 'battery_power' => '电量',
- 'is_link' => '是否在线',
- 'is_lock' => '是否锁车',
- 'is_low_battery_power' => '是否电量低',
- 'is_riding' => '是否骑行',
- 'is_trouble' => '是否故障',
- 'last_use_bike_end_time' => '最后骑行时间',
- 'last_location' => '最后位置信息',
- 'last_location_time' => '最后定位时间',
- 'put_area_id' => '投放区域id',
- 'put_status' => '投放状态',
- 'put_time' => '投放时间',
- ];
- }
- }
|