migrate to gtea from bistbucket
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\RestaurantDelivery\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class RiderResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'full_name' => $this->full_name,
|
||||
'phone' => $this->phone,
|
||||
'email' => $this->email,
|
||||
'photo' => $this->photo_url,
|
||||
|
||||
// Type and Status
|
||||
'type' => $this->type->value,
|
||||
'type_label' => $this->type->label(),
|
||||
'status' => $this->status->value,
|
||||
'status_label' => $this->status->label(),
|
||||
'is_verified' => $this->is_verified,
|
||||
'is_online' => $this->is_online,
|
||||
|
||||
'user_info' => [
|
||||
'restaurant_id' => $this->user?->restaurant_id,
|
||||
'user_id' => $this->user?->id,
|
||||
'email' => $this->user?->email,
|
||||
'phone' => $this->user?->phone,
|
||||
'user_type' => $this->user?->user_type,
|
||||
'fcm_token' => $this->user?->fcm_token,
|
||||
'address' => $this->user?->address,
|
||||
],
|
||||
|
||||
// Vehicle
|
||||
'vehicle' => [
|
||||
'type' => $this->vehicle_type->value,
|
||||
'type_label' => $this->vehicle_type->label(),
|
||||
'number' => $this->vehicle_number,
|
||||
'model' => $this->vehicle_model,
|
||||
'color' => $this->vehicle_color,
|
||||
],
|
||||
|
||||
// Location
|
||||
'location' => $this->when($this->current_latitude && $this->current_longitude, fn () => [
|
||||
'latitude' => (float) $this->current_latitude,
|
||||
'longitude' => (float) $this->current_longitude,
|
||||
'last_update' => $this->last_location_update?->toIso8601String(),
|
||||
]),
|
||||
|
||||
// Distance (only when queried with nearby scope)
|
||||
'distance' => $this->when(isset($this->distance), fn () => round($this->distance, 2)),
|
||||
|
||||
// Stats
|
||||
'stats' => [
|
||||
'rating' => (float) $this->rating,
|
||||
'rating_count' => $this->rating_count,
|
||||
'total_deliveries' => $this->total_deliveries,
|
||||
'successful_deliveries' => $this->successful_deliveries,
|
||||
'acceptance_rate' => (float) $this->acceptance_rate,
|
||||
'completion_rate' => (float) $this->completion_rate,
|
||||
],
|
||||
|
||||
// Commission
|
||||
'commission' => $this->when($request->user()?->isAdmin ?? false, fn () => [
|
||||
'type' => $this->commission_type->value,
|
||||
'rate' => (float) $this->commission_rate,
|
||||
'base' => $this->base_commission ? (float) $this->base_commission : null,
|
||||
'per_km_rate' => $this->per_km_rate ? (float) $this->per_km_rate : null,
|
||||
]),
|
||||
|
||||
// Active deliveries count
|
||||
'active_deliveries_count' => $this->whenLoaded('activeDeliveries', fn () => $this->activeDeliveries->count()),
|
||||
|
||||
// Online status
|
||||
'last_online_at' => $this->last_online_at?->toIso8601String(),
|
||||
|
||||
// Timestamps
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
'verified_at' => $this->verified_at?->toIso8601String(),
|
||||
'verified_by' => $this->verified_by,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user