83 lines
3.1 KiB
PHP
83 lines
3.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\RestaurantDelivery\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateRiderProfileRequest 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.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$riderId = $this->route('rider')?->id;
|
|
|
|
return [
|
|
'first_name' => ['sometimes', 'string', 'max:100'],
|
|
'last_name' => ['sometimes', 'string', 'max:100'],
|
|
'email' => [
|
|
'sometimes',
|
|
'email',
|
|
'max:255',
|
|
Rule::unique('restaurant_riders', 'email')->ignore($riderId),
|
|
],
|
|
'phone' => [
|
|
'sometimes',
|
|
'string',
|
|
'max:20',
|
|
Rule::unique('restaurant_riders', 'phone')->ignore($riderId),
|
|
],
|
|
'photo_url' => ['nullable', 'string', 'url', 'max:500'],
|
|
'vehicle_type' => ['nullable', Rule::in(['bike', 'motorcycle', 'car', 'bicycle', 'scooter'])],
|
|
'vehicle_number' => ['nullable', 'string', 'max:50'],
|
|
'license_number' => ['nullable', 'string', 'max:50'],
|
|
'license_expiry' => ['nullable', 'date', 'after:today'],
|
|
'bank_name' => ['nullable', 'string', 'max:100'],
|
|
'bank_account_number' => ['nullable', 'string', 'max:50'],
|
|
'bank_branch' => ['nullable', 'string', 'max:100'],
|
|
'mobile_banking_provider' => ['nullable', 'string', 'max:50'],
|
|
'mobile_banking_number' => ['nullable', 'string', 'max:20'],
|
|
'preferred_payment_method' => ['nullable', Rule::in(['bank_transfer', 'bkash', 'nagad', 'rocket'])],
|
|
'preferred_zones' => ['nullable', 'array'],
|
|
'preferred_zones.*' => ['integer', 'exists:restaurant_delivery_zones,id'],
|
|
'emergency_contact_name' => ['nullable', 'string', 'max:100'],
|
|
'emergency_contact_phone' => ['nullable', 'string', 'max:20'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'first_name' => 'first name',
|
|
'last_name' => 'last name',
|
|
'photo_url' => 'profile photo',
|
|
'vehicle_type' => 'vehicle type',
|
|
'vehicle_number' => 'vehicle number',
|
|
'license_number' => 'license number',
|
|
'license_expiry' => 'license expiry date',
|
|
'bank_account_number' => 'bank account number',
|
|
'mobile_banking_provider' => 'mobile banking provider',
|
|
'mobile_banking_number' => 'mobile banking number',
|
|
'preferred_payment_method' => 'preferred payment method',
|
|
'preferred_zones' => 'preferred delivery zones',
|
|
'emergency_contact_name' => 'emergency contact name',
|
|
'emergency_contact_phone' => 'emergency contact phone',
|
|
];
|
|
}
|
|
}
|