initial: project state before operator dashboard card redesign
This commit is contained in:
commit
e0aed8eed7
113 files changed
+20074
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Models\ParkingLot;
|
||||
|
||||
class StoreBookingRequest 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 this request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'parking_lot_id' => 'required|exists:parking_lots,id',
|
||||
'customer_name' => 'required|string|max:255',
|
||||
'phone' => 'required|string|max:20|regex:/^09[0-9]{8}$/',
|
||||
'start_time' => 'required|date|after:now',
|
||||
'end_time' => 'required|date|after:start_time',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'phone.regex' => 'رقم الهاتف يجب أن يكون رقم سوري صالح (09xxxxxxxx).',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the validator after the validation rules have run.
|
||||
*/
|
||||
protected function passedValidation(): void
|
||||
{
|
||||
$lot = ParkingLot::findOrFail($this->parking_lot_id);
|
||||
$activeCount = $lot->carRegistries()->active()->count();
|
||||
|
||||
if ($lot->total_capacity <= $activeCount) {
|
||||
throw \Illuminate\Validation\ValidationException::withMessages([
|
||||
'parking_lot_id' => ['الموقف ممتلئ حالياً. يرجى اختيار موقف آخر أو المحاولة لاحقاً.'],
|
||||
])->status(409);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreOperatorCheckInRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true; // Enforce via operator middleware
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'parking_lot_id' => 'required|exists:parking_lots,id',
|
||||
'vehicle_plate' => 'required|string|max:50',
|
||||
'user_name' => 'nullable|string|max:255',
|
||||
'user_phone' => 'nullable|string|max:20',
|
||||
'duration_hours' => 'required|numeric|min:0.25|max:24',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'vehicle_plate.required' => 'رقم اللوحة مطلوب.',
|
||||
'parking_lot_id.exists' => 'موقف السيارات غير موجود.',
|
||||
'duration_hours.required' => 'مدة الإقامة مطلوبة.',
|
||||
];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreParkingLotRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true; // Enforce via middleware
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'address' => 'required|string|max:500',
|
||||
'total_capacity' => 'required|integer|min:1|max:10000',
|
||||
'price_per_hour' => 'required|numeric|min:0.01|max:1000',
|
||||
'latitude' => 'required|numeric|between:-90,90',
|
||||
'longitude' => 'required|numeric|between:-180,180',
|
||||
'working_hours' => 'required|string|max:100',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'اسم الموقف مطلوب.',
|
||||
'address.required' => 'العنوان مطلوب.',
|
||||
'total_capacity.required' => 'السعة مطلوبة.',
|
||||
'price_per_hour.required' => 'سعر الساعة مطلوب.',
|
||||
'latitude.required' => 'خط العرض مطلوب.',
|
||||
'longitude.required' => 'خط الطول مطلوب.',
|
||||
];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in new issue
Block a user