initial: project state before operator dashboard card redesign

This commit is contained in:
ghassan committed 2026-04-15 11:39:10 +03:00
commit e0aed8eed7
113 files changed
+20074

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class BookingResource extends JsonResource
{
/**
* Transform the resource into an array.
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'parking_lot_id' => $this->parking_lot_id,
'parking_lot' => $this->whenLoaded('parkingLot', fn() => [
'id' => $this->parkingLot->id,
'name' => $this->parkingLot->name,
]),
'customer_name' => $this->customer_name,
'phone' => $this->phone,
'start_time' => $this->start_time->toIso8601String(),
'end_time' => $this->end_time->toIso8601String(),
'status' => $this->status,
];
}
}
?>
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class CarRegistryResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'plate_number' => $this->plate_number,
'entry_time' => $this->entry_time,
'exit_time' => $this->exit_time,
'is_active' => $this->active,
'duration_hours' => $this->entry_time ? $this->entry_time->diffInHours(now()) : null,
'parking_lot' => new ParkingLotResource($this->whenLoaded('parkingLot')),
];
}
}
?>
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ParkingLotResource extends JsonResource
{
/**
* Transform the resource into an array.
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'address' => $this->address,
'total_capacity' => $this->total_capacity,
'occupied_spaces' => $this->occupied_spaces,
'available_spaces' => $this->available_spaces,
'usage_percentage' => $this->usage_percentage,
'active_registries_count' => $this->active_registries_count ?? 0,
'active_bookings_count' => $this->active_bookings_count ?? 0,
'price_per_hour' => $this->price_per_hour,
'working_hours' => $this->working_hours,
'lat' => $this->latitude,
'lng' => $this->longitude,
'status' => $this->getAvailabilityStatus(),
];
}
private function getAvailabilityStatus()
{
$available = $this->available_spaces;
$total = $this->total_capacity;
if ($available === 0) return 'full';
if ($available < $total * 0.2) return 'limited';
return 'available';
}
}
?>