// SYSTEM PANEL //
[ROOT]
/
mnt
/
pleskStorage
/
vhosts
/
kodsolutions.net
/
subdomains
/
go-rent.kodsolutions.net
/
app
/
Services
/
Booking
[ PARENT ]
EDIT :: BookingCalculationService.php
<?php namespace App\Services\Booking; use DateTime; class BookingCalculationService { public function calculate(string $pickupDate, string $dropoffDate, \App\Models\Car\Car $car): array { $checkInDate = new DateTime($pickupDate); $checkOutDate = new DateTime($dropoffDate); $interval = $checkInDate->diff($checkOutDate); $days = max($interval->days, 1); if ($days >= 30) { return [ 'number_of_days' => $days, 'total_price' => $days * $car->monthly_price, ]; } if ($days >= 7 && $days < 30) { return [ 'number_of_days' => $days, 'total_price' => $days * $car->weekly_price, ]; } return [ 'number_of_days' => $days, 'total_price' => $days * $car->daily_price, ]; } }
SAVE
CANCEL