// SYSTEM PANEL //
[ROOT]
/
mnt
/
pleskStorage
/
vhosts
/
kodsolutions.net
/
subdomains
/
go-rent.kodsolutions.net
/
app
/
Http
/
Requests
[ PARENT ]
EDIT :: CarRequest.php
<?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class CarRequest extends FormRequest { public function rules() { $route = $this->route()->getName(); switch ($this->method()) { // CREATE case 'POST': $validate = [ 'position' => 'required_if:route,admin.*', 'active' => 'required_if:route,admin.*', 'best_deal' => 'nullable|boolean', 'sponsored' => 'nullable|boolean', 'featured' => 'nullable|boolean', 'in_home' => 'nullable|boolean', 'status_id' => 'required|exists:categories,id', 'expired_at' => 'nullable|date', 'tags' => 'nullable|string', 'keywords' => 'nullable|string', 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', 'plate_number' => 'required|string|max:255', 'car_license' => 'required|file|mimes:jpeg,png,jpg,gif,pdf|max:2048', 'office_id' => 'required_if:route,admin.*|exists:offices,id', 'brand_id' => 'nullable|exists:categories,id', 'model_id' => 'required|exists:categories,id', 'year_id' => 'required|exists:categories,id', 'category_id' => 'required|exists:categories,id', 'vehicle_type_id' => 'required|exists:categories,id', 'fuel_type_id' => 'required|exists:categories,id', 'transmission_id' => 'required|exists:categories,id', 'insurance_type_id' => 'required|exists:categories,id', 'color_id' => 'required|exists:categories,id', 'accept_immediately' => 'required_if:route,admin.*|boolean', 'immediately_time' => 'required_if:route,admin.*|date_format:H:i', 'is_available' => 'required_if:route,admin.*|boolean', 'price' => 'required|numeric|min:0', 'special_price' => 'nullable|numeric|min:0', 'discount' => 'nullable|numeric|min:0|max:100', 'daily_price' => 'required|numeric|min:0', 'weekly_price' => 'required|numeric|min:0', 'monthly_price' => 'required|numeric|min:0', 'daily_mileage_limit' => 'required|numeric|min:0', 'excess_mileage_fee' => 'required|numeric|min:0', 'seating_capacity' => 'required|numeric|min:1|max:50', 'city_id' => 'required_if:route,admin.*|exists:cities,id', 'area_id' => 'required_if:route,admin.*|exists:cities,id', 'branch_id' => 'nullable|exists:branches,id', 'payment_method' => 'nullable|integer|min:0|max:5', 'document' => 'nullable|array', 'document.*' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048', 'title' => 'required_if:route,website.*|string|max:255', 'description' => 'nullable|string', 'sub_title' => 'nullable|string|max:255', ]; foreach (\Illuminate\Support\Facades\Config::get('app.locales') as $locale) { $validate['title.' . $locale] = 'nullable|string|max:255'; $validate['description.' . $locale] = 'nullable|string'; $validate['sub_title.' . $locale] = 'nullable|string|max:255'; } return $validate; // UPDATE case 'PUT': case 'PATCH': $validate = [ 'position' => 'nullable', 'active' => 'nullable', 'best_deal' => 'nullable|boolean', 'sponsored' => 'nullable|boolean', 'featured' => 'nullable|boolean', 'in_home' => 'nullable|boolean', 'status_id' => 'nullable|exists:categories,id', 'expired_at' => 'nullable|date', 'tags' => 'nullable|string', 'keywords' => 'nullable|string', 'image' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048', 'plate_number' => 'nullable|string|max:255', 'car_license' => 'nullable|file|mimes:jpeg,png,jpg,gif,pdf|max:2048', 'office_id' => 'nullable|exists:offices,id', 'brand_id' => 'nullable|exists:categories,id', 'model_id' => 'nullable|exists:categories,id', 'year_id' => 'nullable|exists:categories,id', 'category_id' => 'nullable|exists:categories,id', 'vehicle_type_id' => 'nullable|exists:categories,id', 'fuel_type_id' => 'nullable|exists:categories,id', 'transmission_id' => 'nullable|exists:categories,id', 'insurance_type_id' => 'nullable|exists:categories,id', 'color_id' => 'nullable|exists:categories,id', 'accept_immediately' => 'nullable|boolean', 'immediately_time' => 'nullable|date_format:H:i', 'is_available' => 'nullable|boolean', 'price' => 'nullable|numeric|min:0', 'special_price' => 'nullable|numeric|min:0', 'discount' => 'nullable|numeric|min:0|max:100', 'daily_price' => 'nullable|numeric|min:0', 'weekly_price' => 'nullable|numeric|min:0', 'monthly_price' => 'nullable|numeric|min:0', 'daily_mileage_limit' => 'nullable|numeric|min:0', 'excess_mileage_fee' => 'nullable|numeric|min:0', 'seating_capacity' => 'nullable|numeric|min:1|max:50', 'city_id' => 'nullable|exists:cities,id', 'area_id' => 'nullable|exists:cities,id', 'branch_id' => 'nullable|exists:branches,id', 'payment_method' => 'nullable|integer|min:0|max:5', 'document' => 'nullable|array', 'document.*' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048', 'title' => 'nullable|string|max:255', 'description' => 'nullable|string', 'sub_title' => 'nullable|string|max:255', ]; foreach (\Illuminate\Support\Facades\Config::get('app.locales') as $locale) { $validate['title.' . $locale] = 'nullable|string|max:255'; $validate['description.' . $locale] = 'nullable|string'; $validate['sub_title.' . $locale] = 'nullable|string|max:255'; } return $validate; case 'GET': case 'DELETE': default: return []; } } public function messages() { return [ 'tags.string' => 'الوسوم يجب أن تكون نصاً مفصولاً بفواصل', 'keywords.string' => 'الكلمات المفتاحية يجب أن تكون نصاً مفصولاً بفواصل', 'brand_id.required' => 'يجب اختيار الماركة', 'model_id.required' => 'يجب اختيار الموديل', 'year_id.required' => 'يجب اختيار السنة', 'vehicle_type_id.required' => 'يجب اختيار نوع المركبة', 'fuel_type_id.required' => 'يجب اختيار نوع الوقود', 'transmission_id.required' => 'يجب اختيار نوع ناقل الحركة', 'color_id.required' => 'يجب اختيار اللون', 'price.required' => 'يجب إدخال السعر', 'price.numeric' => 'السعر يجب أن يكون رقماً', 'price.min' => 'السعر يجب أن يكون أكبر من الصفر', 'seating_capacity.max' => 'عدد المقاعد يجب أن لا يتجاوز 50 مقعد', 'position.required' => 'يجب إدخال الترتيب', 'expired_at.date' => 'تاريخ الانتهاء يجب أن يكون تاريخاً صحيحاً', 'image.image' => 'الصورة يجب أن تكون ملف صورة', 'image.mimes' => 'الصورة يجب أن تكون بصيغة jpeg، png، jpg أو gif', 'image.max' => 'حجم الصورة يجب ألا يتجاوز 2 ميجابايت', 'plate_number.max' => 'رقم اللوحة يجب ألا يتجاوز 255 حرفاً', 'car_license.file' => 'رخصة السيارة يجب أن تكون ملف صورة أو PDF', 'car_license.mimes' => 'رخصة السيارة يجب أن تكون بصيغة jpeg، png، jpg، gif أو pdf', 'car_license.max' => 'حجم ملف رخصة السيارة يجب ألا يتجاوز 2 ميجابايت', 'daily_price.numeric' => 'السعر اليومي يجب أن يكون رقماً', 'daily_price.min' => 'السعر اليومي يجب أن يكون أكبر من الصفر', 'weekly_price.numeric' => 'السعر الأسبوعي يجب أن يكون رقماً', 'weekly_price.min' => 'السعر الأسبوعي يجب أن يكون أكبر من الصفر', 'monthly_price.numeric' => 'السعر الشهري يجب أن يكون رقماً', 'monthly_price.min' => 'السعر الشهري يجب أن يكون أكبر من الصفر', 'daily_mileage_limit.numeric' => 'حد المسافة اليومي يجب أن يكون رقماً', 'daily_mileage_limit.min' => 'حد المسافة اليومي يجب أن يكون أكبر من الصفر', 'excess_mileage_fee.numeric' => 'رسوم المسافة الزائدة يجب أن تكون رقماً', 'excess_mileage_fee.min' => 'رسوم المسافة الزائدة يجب أن تكون أكبر من الصفر', 'immediately_time.date_format' => 'وقت القبول الفوري يجب أن يكون بتنسيق الساعة الصحيح', 'payment_method.integer' => 'طريقة الدفع يجب أن تكون رقماً صحيحاً', 'payment_method.min' => 'طريقة الدفع غير صالحة', 'payment_method.max' => 'طريقة الدفع غير صالحة', 'document.array' => 'الصور يجب أن تكون ملفات صورة', 'document.*.image' => 'الصور يجب أن تكون ملفات صورة', 'document.*.mimes' => 'الصور يجب أن تكون بصيغة jpeg، png، jpg أو gif', 'document.*.max' => 'حجم الصورة يجب ألا يتجاوز 2 ميجابايت', ]; } }
SAVE
CANCEL