15 lines
366 B
PHP
15 lines
366 B
PHP
|
<?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);
|
||
|
}
|
||
|
}
|