Files
backend/app/Http/Requests/V3/RoadMaintenanceStation/StoreRequest.php

58 lines
2.0 KiB
PHP

<?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',
];
}
}