Is it possible to use a variable as the call to a Laravel Blade directive? For my menu system, I've defined a component and I would like to be able to set the visibility of a link in the component. I have created numerous Blade directives ('staff', 'admin', 'client' etc.) which checks a user's role.
My component definition looks like this:
@component('components.primaryMenu', [
'items' => [
[
'route' => route('some.uri'),
'visibility' => ['staff', 'client'],
'label' => 'Item 1',
],
[
'route' => route('another.uri'),
'visibility' => ['everyone'],
'label' => 'Item 2',
],
]
])@endcomponent
What I would like to do is:
<ul class="nav">
@foreach($items as $item)
@foreach($item['visibility'] as $visibility)
@ // Should become @staff / @client
// Link stuff in here
@end // Should become @endstaff / @endclient
@endforeach
@endforeach
</ul>
When I run this code I get "Invalid argument supplied for foreach()". I'm guessing because the @ declarations are throwing off the parser.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iZMxI5
via IFTTT
Aucun commentaire:
Enregistrer un commentaire