Overview of upcoming events
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Enumerations\UserRole;
|
||||
use App\Models\CostUnit;
|
||||
use App\Models\Event;
|
||||
use App\Resources\CostUnitResource;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Psy\Readline\Hoa\EventBucket;
|
||||
|
||||
class EventRepository {
|
||||
@@ -17,11 +19,20 @@ class EventRepository {
|
||||
|
||||
}
|
||||
|
||||
public function getUpcomming() : array {
|
||||
return $this->getEventsByCriteria([
|
||||
public function getUpcoming(int $maxCount = 5, bool $accessCheck = true) : array {
|
||||
$events = [];
|
||||
foreach ( $this->getEventsByCriteria([
|
||||
'archived' => false,
|
||||
'upcomming' => true
|
||||
]);
|
||||
|
||||
],$accessCheck) as $event) {
|
||||
if ($event->start_date > now()) {
|
||||
$event = $event->toResource()->toArray(new Request());
|
||||
|
||||
$events[] = $event;
|
||||
}
|
||||
};
|
||||
|
||||
return array_slice($events, 0, $maxCount);
|
||||
}
|
||||
|
||||
public function getAvailable(bool $accessCheck = true) : array {
|
||||
|
||||
Reference in New Issue
Block a user