create show,store,update and delete for RoadMaintenanceStationController
This commit is contained in:
57
app/Http/Requests/V3/RoadMaintenanceStation/StoreRequest.php
Normal file
57
app/Http/Requests/V3/RoadMaintenanceStation/StoreRequest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadMaintenanceStation;
|
||||
|
||||
use App\Models\RahdariPoint;
|
||||
use Hekmatinasser\Verta\Facades\Verta;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->hasPermissionTo('add-tollhouse') ||
|
||||
($user->hasPermissionTo('add-tollhouse-province') && $this->province_id == $user->province_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 [
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'city_id' => 'required|exists:cities,id',
|
||||
'name' => 'required|string|max:255',
|
||||
'status' => 'required|in:0,1',
|
||||
'type' =>'required|in:1,2,3',
|
||||
'team_num' => 'numeric',
|
||||
'staff_num' => 'numeric',
|
||||
'phone' => 'string|max:50',
|
||||
'responsible_name' => 'string|max:255',
|
||||
'responsible_mobile' => 'string|max:50',
|
||||
'successor_name' => 'string|max:255',
|
||||
'successor_mobile' => 'string|max:50',
|
||||
'machines_light' => 'numeric',
|
||||
'machines_sheavy' => 'numeric',
|
||||
'machines_heavy' => 'numeric',
|
||||
'code' => 'string|max:50',
|
||||
'lat' => 'numeric',
|
||||
'lng' => 'numeric',
|
||||
'overview_files_1' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
'overview_files_2' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
'overview_files_3' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
'overview_files_4' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
'overview_files_5' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadMaintenanceStation;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest 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 [
|
||||
'status' => 'integer|in:0,1',
|
||||
'type' => 'integer|in:1,2,3',
|
||||
'team_num' => 'numeric',
|
||||
'staff_num' => 'numeric',
|
||||
'phone' => 'string|max:50',
|
||||
'responsible_name' => 'string|max:255',
|
||||
'responsible_mobile' => 'string|max:50',
|
||||
'successor_name' => 'string|max:255',
|
||||
'successor_mobile' => 'string|max:50',
|
||||
'machines_light' => 'numeric',
|
||||
'machines_sheavy' => 'numeric',
|
||||
'machines_heavy' => 'numeric',
|
||||
'lat' => 'numeric',
|
||||
'lng' => 'numeric',
|
||||
'lat_from' => 'numeric',
|
||||
'lng_from' => 'numeric',
|
||||
'lat_to' => 'numeric',
|
||||
'lng_to' => 'numeric',
|
||||
'color' => 'numeric',
|
||||
'geometry' => 'numeric',
|
||||
'overview_files_1' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
'overview_files_2' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
'overview_files_3' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
'overview_files_4' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
'overview_files_5' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user