Overview of upcoming events

This commit is contained in:
2026-04-25 21:23:32 +02:00
parent f813056bf7
commit 8348f677a5
7 changed files with 108 additions and 8 deletions

View File

@@ -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 {