47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V3\Mission;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
$user = $this->user();
|
|
return $user->hasPermissionTo('mission-manage-country') ||
|
|
($user->hasPermissionTo('mission-manage-province') && $this->province_id == $user->province_id)||
|
|
($user->hasPermissionTo('mission-manage-city') && $this->province_id == $user->province_id && $this->city_id == $user->city_id);
|
|
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'machine_id' => 'nullable|exists:cmms_machines|id',
|
|
'machine_id.*' => 'exists:cmms_machines,id',
|
|
'rahdar_id' => 'required|exists:rahdaran|id',
|
|
'rahdar_id.*' => 'exists:rahdaran,id',
|
|
'state_id' => 'required|exists:mission_states|id',
|
|
'state_name' => 'required|string|max:255',
|
|
'requested_machine_type' => 'required|string|max:255',
|
|
'requested_machine_numbers'=> 'required|string|max:255',
|
|
'type' => 'required'|'string'|'max:50',
|
|
'start_date' => 'required|date',
|
|
'end_date' => 'required|date',
|
|
'request_date' => 'required|date',
|
|
'description' => 'nullable|string',
|
|
'start_point' => 'required|string|max:255',
|
|
'end_point' => 'required|string|max:255',
|
|
];
|
|
}
|
|
}
|