transfer road item project from v2 to v3
This commit is contained in:
73
app/Http/Requests/V3/RoadItemsProject/StoreRequest.php
Normal file
73
app/Http/Requests/V3/RoadItemsProject/StoreRequest.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadItemsProject;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'start_point' => 'required',
|
||||
'item_id' => 'required|integer',
|
||||
'sub_item_id' => 'required|integer',
|
||||
'amount' => 'required|numeric',
|
||||
'observed_item_id' => 'integer|exists:observed_items,id',
|
||||
'activity_date' => 'required|date_format:Y-m-d',
|
||||
'activity_time' => 'required|date_format:H:i',
|
||||
'before_image' => 'image|max:4096',
|
||||
'after_image' => 'image|max:4096',
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'activity_date' => 'تاریخ فعالیت',
|
||||
'activity_time' => 'ساعت فعالیت',
|
||||
];
|
||||
}
|
||||
|
||||
// public function after(): array
|
||||
// {
|
||||
// return [
|
||||
// function (Validator $validator) {
|
||||
// if ($this->has(['item_id', 'sub_item_id'])) {
|
||||
//
|
||||
// $info_item = InfoItem::query()
|
||||
// ->where('item', $this->item_id)
|
||||
// ->where('sub_item', $this->sub_item_id)
|
||||
// ->firstOrFail();
|
||||
//
|
||||
// if ($info_item->needs_end_point && !$this->filled('end_point')) {
|
||||
// $validator->errors()->add('end_point', __('validation.required'));
|
||||
// }
|
||||
//
|
||||
// if ($info_item->needs_image) {
|
||||
// if (!$this->hasFile('before_image')) {
|
||||
// $validator->errors()->add('before_image', __('validation.required'));
|
||||
// }
|
||||
// if (!$this->hasFile('after_image')) {
|
||||
// $validator->errors()->add('after_image', __('validation.required'));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ];
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user