Add event meta

This commit is contained in:
philipp lang 2024-03-06 22:07:04 +01:00
parent bed2227796
commit df7c0a2346
4 changed files with 10 additions and 3 deletions

@ -1 +1 @@
Subproject commit 71c92559b8c220442b43d9ea52bbcb8e9bb23221
Subproject commit e0ab18a469a831b85f61e10f32d1ad6ede366f43

View File

@ -8,13 +8,13 @@ use Cms\Classes\Page;
use Silva\Adrema\Exceptions\ComponentException;
use Silva\Adrema\Models\Settings;
use Silva\Adrema\Support\FetchAllEvents;
use Silva\Adrema\Support\FetchSingleEvent;
abstract class EventManager extends ComponentBase
{
public array $settings = [];
public ?array $event = null;
public array $eventMeta = [];
/** @var Collection<int, mixed> */
public Collection $events;
@ -149,6 +149,7 @@ 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']);
$this->event = $this->page['event'] = $this->events->first(fn ($event) => $event['slug'] == $eventSlug);
$this->currentUrl = url()->current();

View File

@ -21,7 +21,12 @@ class Proxy
public function submit(string $url): JsonResponse
{
$response = Http::acceptJson()->post($this->url($url), request()->input());
$headers = request()->header('X-Adrema-Token')
? [
'Authorization' => 'Bearer ' . request()->header('X-Adrema-Token'),
]
: [];
$response = Http::acceptJson()->withHeaders($headers)->post($this->url($url), request()->input());
return response()->json($response->json(), $response->status());
}

View File

@ -9,6 +9,7 @@
<script type="text/javascript">
var adrema_event_config = {{__SELF__.event.config | json_encode | raw}};
var adrema_event_meta = {{__SELF__.eventMeta | json_encode | raw}};
</script>
{% endif %}