wi-adrema-plugin/support/FetchSingleEvent.php

15 lines
366 B
PHP
Raw Normal View History

2024-02-03 22:36:56 +01:00
<?php
namespace Silva\Adrema\Support;
class FetchSingleEvent
{
public function run(string $slug): ?array
{
$events = data_get(app(FetchAllEvents::class)->run(), 'data');
throw_if(is_null($events), ComponentException::class, 'event_fetching_failed');
return collect($events)->first(fn ($event) => $event['slug'] === $slug);
}
}