wah.moe/app/View/Components/Layout.php

35 lines
847 B
PHP
Raw Normal View History

<?php
namespace App\View\Components;
use Closure;
2024-12-27 20:28:16 +00:00
use DateTime;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
2024-12-27 20:28:16 +00:00
class Layout extends Component {
/**
* Create a new component instance.
*/
2024-12-27 20:28:16 +00:00
public function __construct() {}
/**
* Get the view / contents that represent the component.
*/
2024-12-27 20:28:16 +00:00
public function render(): View|Closure|string {
return view('components.layout', [
'isChristmas' => $this->isItChristmas()
]);
}
public function isItChristmas() : bool {
$currentDate = new DateTime();
$currentYear = intval($currentDate->format('Y'));
$startDate = new DateTime("$currentYear-11-10");
$endDate = new DateTime(($currentYear + 1) . "-01-01");
return $currentDate >= $startDate && $currentDate < $endDate;
}
}