create controller
This commit is contained in:
46
app/Http/Requests/V3/Mission/StoreRequest.php
Normal file
46
app/Http/Requests/V3/Mission/StoreRequest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Requests/V3/Mission/UpdateRequest.php
Normal file
28
app/Http/Requests/V3/Mission/UpdateRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user