File: D:/HostingSpaces/centrum8a/centrum8a.com/app/KommaApp/Dates/DateService.php
<?php
namespace App\KommaApp\Dates;
use App\KommaApp\Dates\Models\Date;
use Carbon\Carbon;
class DateService
{
private $today;
public function __construct()
{
$this->today = Carbon::now()->addHour();
$this->today = $this->today->format('Y-m-d H:i:s');
}
public function getAllDates($pagination = false, $itemsPerPage = 9)
{
$dates = \App::getSite()
->dates()
->with('translation', 'images')
->where('active', 1)
->where('date', '>=', $this->today)
->orderBy('date','asc')
->orderBy('created_at', 'asc');
if($pagination)
{
$dates = $dates->paginate($itemsPerPage);
}
else
{
$dates = $dates->get();
}
return $dates;
}
public function getLatestDates($amount = 5){
return $dates = \App::getSite()
->dates()
->with('translation', 'images')
->where('active', 1)
->where('date', '<=', $this->today)
->orderBy('date','desc')
->orderBy('created_at', 'desc')
->take($amount)
->get();
}
}