Server-side "is it christmas"
This commit is contained in:
parent
3e97458ee2
commit
0a50c93d3a
3 changed files with 21 additions and 26 deletions
|
@ -3,24 +3,32 @@
|
|||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use DateTime;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Layout extends Component
|
||||
{
|
||||
class Layout extends Component {
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
public function __construct() {}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.layout');
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue