Add caching for events
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
3ec9149d75
commit
6f268a224b
|
@ -149,8 +149,9 @@ abstract class EventManager extends ComponentBase
|
|||
return;
|
||||
}
|
||||
|
||||
$this->eventMeta = data_get(app(FetchAllEvents::class)->run(), 'meta', []);
|
||||
$this->events = $this->page['events'] = collect(app(FetchAllEvents::class)->run()['data']);
|
||||
$eventData = app(FetchAllEvents::class)->run();
|
||||
$this->eventMeta = data_get($eventData, 'meta', []);
|
||||
$this->events = $this->page['events'] = collect($eventData['data']);
|
||||
$this->event = $this->page['event'] = $this->events->first(fn ($event) => $event['slug'] == $eventSlug);
|
||||
$this->currentUrl = url()->current();
|
||||
}
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
namespace Silva\Adrema\Support;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Cache;
|
||||
|
||||
class FetchAllEvents
|
||||
{
|
||||
public function run(): ?Collection
|
||||
{
|
||||
$events = app(Proxy::class)->run('/api/form');
|
||||
$events = Cache::remember('adrema-all-events', 3600, function () {
|
||||
return app(Proxy::class)->run('/api/form');
|
||||
});
|
||||
|
||||
if (!$events) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue