Update:
I managed to submit the key of the clicked thumbnail to Vue.
Here's the route (with associative array now):
Route::get('/ludwigsburger_strasse', function () {
$header = "home";
$pics = [
0 => 'Praxisbild_LB1',
1 =>'Praxisbild_LB2',
2 => 'Praxisbild_LB3',
3 => 'Praxisbild_LB4'];
return view('pages.standorte.alleecenter', compact('header', 'pics')); })->name('ludwigsburger');
And here's the thumbnail gallery:
<div class="galleryBox">
@foreach ($pics as $key => $pic)
<figure @click="key={{ $key }}">
<img src="/img/standorte/{{ $pic }}_thumbnail.jpg" @click="showGalleryModal=true">
</figure>
@endforeach
</div>
The app.js:
Vue.component('modal', {
props: ['key'],
template: `
<div class="modal is-active">
<div class="modal-background"></div>
<div class="modal-content">
<slot></slot>
</div>
<button class="modal-close is-large" aria-label="close" @click="$emit('close')"></button>
</div>
`
});
new Vue({
el: '#root',
data: {
showGalleryModal: false,
key: ''
}
});
And the modal component in HTML:
<modal v-if="showGalleryModal" @close="showGalleryModal=false">
<h3>@{{ key }}</h3>
<figure class="image">
<img src="...">
</figure>
</modal>
The h3 in the modal element returns the key from above correctly. But how can I find the proper name (value) belonging to the key in the $pics array? And how can I put together the proper img src attribute?