Files
postshop-backend/app/Repositories/Ecommerce/Order/OrderRepository.php

59 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Repositories\Ecommerce\Order;
use App\Models\Ecommerce\Product\Order\Shipping\OrderShipping;
class OrderRepository
{
/**
* Available times
*
* @return array<string, mixed>
*/
public static function availableTimes(): array
{
$today = now()->format('d.m.Y');
$tomorrow = now()->addHour(24)->format('d.m.Y');
$times = [
'today' => [],
'tomorrow' => [],
];
if (strtotime('now') <= strtotime('09:00')) {
$times['today'][] = [
'date' => $today,
'hour' => OrderShipping::MORNING,
];
}
if (strtotime('now') <= strtotime('13:00')) {
$times['today'][] = [
'date' => $today,
'hour' => OrderShipping::EVENING,
];
}
$times['tomorrow'] = [
[
'date' => $tomorrow,
'hour' => OrderShipping::MORNING,
],
[
'date' => $tomorrow,
'hour' => OrderShipping::EVENING,
],
];
return [
'dates' => [
'today' => $today,
'tomorrow' => $tomorrow,
],
'hours' => $times,
];
}
}