ctf0

how to share @php block across partials

Posted 2 years ago by ctf0

lets say we have a var call routeName that we want to share across several views,

@php
    $routeName = Route::currentRouteName();
@endphp 

so maybe we make a partial vars.blade.php and include it in each view we want this var

@include('_partials.vars')

but unfortunately this doesnt work, and i keep getting Undefined variable: routeName.

i tried to use @set but nothing changed, so did anyone came across such scenario ?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.