migrate to gtea from bistbucket

This commit is contained in:
2026-03-15 17:08:23 +07:00
commit 129ca2260c
3716 changed files with 566316 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Modules\RestaurantDelivery\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class AssignRiderRequest 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
{
return [
'rider_id' => ['required', 'integer', 'exists:restaurant_riders,id'],
'force_assign' => ['boolean'],
'notes' => ['nullable', 'string', 'max:255'],
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'rider_id' => 'rider',
'force_assign' => 'force assignment',
];
}
/**
* Prepare the data for validation.
*/
protected function prepareForValidation(): void
{
$this->merge([
'force_assign' => $this->boolean('force_assign'),
]);
}
}

View File

@@ -0,0 +1,127 @@
<?php
declare(strict_types=1);
namespace Modules\RestaurantDelivery\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
/**
* CreateDeliveryRequest
*
* IMPORTANT: restaurant_id is NEVER accepted from request input.
* It is always obtained via getUserRestaurantId() in the controller.
*/
class CreateDeliveryRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
// User must be authenticated and have a restaurant_id
return auth()->check() && getUserRestaurantId() !== null;
}
/**
* Get the validation rules that apply to the request.
*
* NOTE: restaurant_id is NOT in this list - it comes from getUserRestaurantId()
*/
public function rules(): array
{
return [
// Order Info
'orderable_type' => ['nullable', 'string', 'max:255'],
'orderable_id' => ['nullable', 'integer'],
'zone_id' => ['nullable', 'integer', 'exists:restaurant_delivery_zones,id'],
// Pickup Details
'restaurant_name' => ['required', 'string', 'max:255'],
'pickup_address' => ['required', 'string', 'max:500'],
'pickup_latitude' => ['required', 'numeric', 'between:-90,90'],
'pickup_longitude' => ['required', 'numeric', 'between:-180,180'],
'pickup_contact_name' => ['nullable', 'string', 'max:100'],
'pickup_contact_phone' => ['nullable', 'string', 'max:20'],
'pickup_instructions' => ['nullable', 'string', 'max:500'],
// Drop-off Details
'customer_name' => ['required', 'string', 'max:100'],
'drop_address' => ['required', 'string', 'max:500'],
'drop_latitude' => ['required', 'numeric', 'between:-90,90'],
'drop_longitude' => ['required', 'numeric', 'between:-180,180'],
'drop_contact_name' => ['nullable', 'string', 'max:100'],
'drop_contact_phone' => ['required', 'string', 'max:20'],
'drop_instructions' => ['nullable', 'string', 'max:500'],
'drop_floor' => ['nullable', 'string', 'max:50'],
'drop_apartment' => ['nullable', 'string', 'max:50'],
// Scheduling
'is_scheduled' => ['boolean'],
'scheduled_for' => ['nullable', 'required_if:is_scheduled,true', 'date', 'after:now'],
'is_priority' => ['boolean'],
// Order Value
'order_value' => ['nullable', 'numeric', 'min:0'],
// Pre-delivery Tip
'tip_amount' => ['nullable', 'numeric', 'min:0'],
'tip_type' => ['nullable', Rule::in(['amount', 'percentage'])],
// Additional Metadata
'meta' => ['nullable', 'array'],
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'pickup_latitude' => 'pickup location latitude',
'pickup_longitude' => 'pickup location longitude',
'drop_latitude' => 'delivery location latitude',
'drop_longitude' => 'delivery location longitude',
'drop_contact_phone' => 'customer phone',
'scheduled_for' => 'scheduled delivery time',
];
}
/**
* Get the error messages for the defined validation rules.
*/
public function messages(): array
{
return [
'pickup_latitude.between' => 'The pickup latitude must be between -90 and 90.',
'pickup_longitude.between' => 'The pickup longitude must be between -180 and 180.',
'drop_latitude.between' => 'The delivery latitude must be between -90 and 90.',
'drop_longitude.between' => 'The delivery longitude must be between -180 and 180.',
'scheduled_for.after' => 'The scheduled delivery time must be in the future.',
'scheduled_for.required_if' => 'The scheduled delivery time is required when scheduling a delivery.',
];
}
/**
* Prepare the data for validation.
*/
protected function prepareForValidation(): void
{
$this->merge([
'is_scheduled' => $this->boolean('is_scheduled'),
'is_priority' => $this->boolean('is_priority'),
]);
}
/**
* Get validated data with restaurant_id from getUserRestaurantId().
*/
public function validatedWithRestaurant(): array
{
return array_merge($this->validated(), [
'restaurant_id' => getUserRestaurantId(),
]);
}
}

View File

@@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
namespace Modules\RestaurantDelivery\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateRatingRequest 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
{
$config = config('restaurant-delivery.rating');
$minRating = $config['min_rating'] ?? 1;
$maxRating = $config['max_rating'] ?? 5;
$maxReviewLength = $config['review_max_length'] ?? 500;
return [
'overall_rating' => ['required', 'integer', "min:{$minRating}", "max:{$maxRating}"],
'speed_rating' => ['nullable', 'integer', "min:{$minRating}", "max:{$maxRating}"],
'communication_rating' => ['nullable', 'integer', "min:{$minRating}", "max:{$maxRating}"],
'food_condition_rating' => ['nullable', 'integer', "min:{$minRating}", "max:{$maxRating}"],
'professionalism_rating' => ['nullable', 'integer', "min:{$minRating}", "max:{$maxRating}"],
'review' => ['nullable', 'string', "max:{$maxReviewLength}"],
'tags' => ['nullable', 'array'],
'tags.*' => ['string', 'max:50'],
'is_anonymous' => ['boolean'],
'is_restaurant_rating' => ['boolean'],
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'overall_rating' => 'overall rating',
'speed_rating' => 'speed rating',
'communication_rating' => 'communication rating',
'food_condition_rating' => 'food condition rating',
'professionalism_rating' => 'professionalism rating',
];
}
/**
* Prepare the data for validation.
*/
protected function prepareForValidation(): void
{
$this->merge([
'is_anonymous' => $this->boolean('is_anonymous'),
'is_restaurant_rating' => $this->boolean('is_restaurant_rating'),
]);
}
/**
* Get validated category ratings as array.
*/
public function categoryRatings(): array
{
return array_filter([
'speed' => $this->validated('speed_rating'),
'communication' => $this->validated('communication_rating'),
'food_condition' => $this->validated('food_condition_rating'),
'professionalism' => $this->validated('professionalism_rating'),
]);
}
}

View File

@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
namespace Modules\RestaurantDelivery\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class CreateTipRequest 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
{
$config = config('restaurant-delivery.tip');
$minTip = $config['min_tip'] ?? 10;
$maxTip = $config['max_tip'] ?? 1000;
$maxPercentage = $config['max_percentage'] ?? 50;
return [
'amount' => ['required', 'numeric', "min:{$minTip}", "max:{$maxTip}"],
'calculation_type' => ['nullable', Rule::in(['fixed', 'percentage'])],
'percentage_value' => [
'nullable',
'required_if:calculation_type,percentage',
'numeric',
'min:1',
"max:{$maxPercentage}",
],
'message' => ['nullable', 'string', 'max:255'],
'type' => ['nullable', Rule::in(['pre_delivery', 'post_delivery'])],
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'amount' => 'tip amount',
'calculation_type' => 'calculation type',
'percentage_value' => 'percentage',
];
}
/**
* Get the error messages for the defined validation rules.
*/
public function messages(): array
{
return [
'percentage_value.required_if' => 'The percentage value is required when using percentage calculation.',
];
}
/**
* Prepare the data for validation.
*/
protected function prepareForValidation(): void
{
if (! $this->has('calculation_type')) {
$this->merge(['calculation_type' => 'fixed']);
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Modules\RestaurantDelivery\Http\Requests\DeliveryZone;
use Illuminate\Foundation\Http\FormRequest;
class DeliveryZoneStoreRequest extends FormRequest
{
public function rules(): array
{
return [
'name' => 'required|string|max:255',
'slug' => 'required|string|max:255|unique:restaurant_delivery_zones,slug',
'description' => 'nullable|string',
'color' => ['nullable', 'regex:/^#[A-Fa-f0-9]{6}$/'],
'coordinates' => 'required|array',
'coordinates.type' => 'required|in:Polygon',
'coordinates.coordinates' => 'required|array|min:1',
'coordinates.coordinates.0' => 'required|array|min:4',
'coordinates.coordinates.0.*' => 'required|array|size:2',
'coordinates.coordinates.0.*.0' => 'required|numeric|between:-180,180',
'coordinates.coordinates.0.*.1' => 'required|numeric|between:-90,90',
'priority' => 'nullable|integer|min:0',
'is_active' => 'nullable|boolean',
'is_default' => 'nullable|boolean',
'max_delivery_distance' => 'nullable|numeric|min:0',
'operating_hours' => 'nullable|array',
'operating_hours.*.open' => 'nullable|date_format:H:i',
'operating_hours.*.close' => 'nullable|date_format:H:i',
'operating_hours.*.enabled' => 'required|boolean',
];
}
public function messages(): array
{
return [
'coordinates.required' => 'Zone polygon is required',
'coordinates.coordinates.0.min' => 'Polygon must contain at least 4 points',
'coordinates.coordinates.0.*.size' => 'Each coordinate must have longitude and latitude',
];
}
public function authorize(): bool
{
return true;
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Modules\RestaurantDelivery\Http\Requests\DeliveryZone;
use Illuminate\Foundation\Http\FormRequest;
class DeliveryZoneUpdateRequest extends FormRequest
{
public function rules(): array
{
return [
'name' => 'required|string|max:255',
'description' => 'nullable|string',
'color' => ['nullable', 'regex:/^#[A-Fa-f0-9]{6}$/'],
'coordinates' => 'required|array',
'coordinates.type' => 'required|in:Polygon',
'coordinates.coordinates' => 'required|array|min:1',
'coordinates.coordinates.0' => 'required|array|min:4',
'coordinates.coordinates.0.*' => 'required|array|size:2',
'coordinates.coordinates.0.*.0' => 'required|numeric|between:-180,180',
'coordinates.coordinates.0.*.1' => 'required|numeric|between:-90,90',
'priority' => 'nullable|integer|min:0',
'is_active' => 'nullable|boolean',
'is_default' => 'nullable|boolean',
'max_delivery_distance' => 'nullable|numeric|min:0',
'operating_hours' => 'nullable|array',
'operating_hours.*.open' => 'nullable|date_format:H:i',
'operating_hours.*.close' => 'nullable|date_format:H:i',
'operating_hours.*.enabled' => 'required|boolean',
];
}
public function messages(): array
{
return [
'coordinates.required' => 'Zone polygon is required',
'coordinates.coordinates.0.min' => 'Polygon must contain at least 4 points',
'coordinates.coordinates.0.*.size' => 'Each coordinate must have longitude and latitude',
];
}
public function authorize(): bool
{
return true;
}
}

View File

@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
namespace Modules\RestaurantDelivery\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Modules\RestaurantDelivery\Enums\DeliveryStatus;
class UpdateDeliveryStatusRequest 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
{
return [
'status' => [
'required',
'string',
Rule::in(array_column(DeliveryStatus::cases(), 'value')),
],
'changed_by' => [
'nullable',
'string',
Rule::in(['customer', 'restaurant', 'rider', 'admin', 'system', 'api']),
],
'notes' => ['nullable', 'string', 'max:500'],
'latitude' => ['nullable', 'numeric', 'between:-90,90'],
'longitude' => ['nullable', 'numeric', 'between:-180,180'],
// For delivery proof
'photo' => ['nullable', 'string'],
'signature' => ['nullable', 'string'],
'recipient_name' => ['nullable', 'string', 'max:100'],
// For cancellation
'cancellation_reason' => [
'nullable',
'required_if:status,cancelled',
'string',
'max:255',
],
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'status' => 'delivery status',
'changed_by' => 'status changed by',
'cancellation_reason' => 'cancellation reason',
];
}
/**
* Get the error messages for the defined validation rules.
*/
public function messages(): array
{
return [
'status.in' => 'The selected status is invalid.',
'cancellation_reason.required_if' => 'A cancellation reason is required when cancelling a delivery.',
];
}
}

View File

@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace Modules\RestaurantDelivery\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRiderLocationRequest 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
{
return [
'latitude' => ['required', 'numeric', 'between:-90,90'],
'longitude' => ['required', 'numeric', 'between:-180,180'],
'speed' => ['nullable', 'numeric', 'min:0', 'max:500'],
'bearing' => ['nullable', 'numeric', 'min:0', 'max:360'],
'accuracy' => ['nullable', 'numeric', 'min:0'],
'altitude' => ['nullable', 'numeric'],
'timestamp' => ['nullable', 'date'],
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'latitude' => 'location latitude',
'longitude' => 'location longitude',
'bearing' => 'direction bearing',
];
}
/**
* Get the error messages for the defined validation rules.
*/
public function messages(): array
{
return [
'latitude.between' => 'The latitude must be between -90 and 90 degrees.',
'longitude.between' => 'The longitude must be between -180 and 180 degrees.',
'bearing.max' => 'The bearing must be between 0 and 360 degrees.',
];
}
}

View File

@@ -0,0 +1,82 @@
<?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',
];
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Modules\RestaurantDelivery\Http\Requests\ZonePricingRule;
use Illuminate\Foundation\Http\FormRequest;
class ZonePricingRuleStoreRequest extends FormRequest
{
public function rules(): array
{
return [
// validation rules
];
}
public function authorize(): bool
{
return true;
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Modules\RestaurantDelivery\Http\Requests\ZonePricingRule;
use Illuminate\Foundation\Http\FormRequest;
class ZonePricingRuleUpdateRequest extends FormRequest
{
public function rules(): array
{
return [
// validation rules
];
}
public function authorize(): bool
{
return true;
}
}