Livewire with custom layout

i see that page:

and try to do that with a View::composer but i get an error
that is my code:

    View::composer('panel/*', function($view)
    {
        $panel_manus = Manu::get();
     
          $view->with('panel_manus',$panel_manus);
    });

my route:
Route::livewire(’/buildit’, ‘panel.buildit’)
->layout(‘layouts.panel’);

but i get an error:

ErrorException
Undefined variable: panel_manus (View:

in other page its work and if i change to
View::composer(’*’, function($view)

its work

but if i add a sub like here: (with “panel” sub folder)
View::composer(‘panel/*’, function($view)

is didnt work

any help :slight_smile:

Hey @haiibooo
Try it without /*

View::composer('panel', function ($view) {
     $panelManus = Manu::get();
    $view->with('panel_menus', $panel_manus);
}); 

See More here

PS: I notice that you have a typo in Manus should be Menus or this another language?

You may use the view:clear command to clear the view cache:

php artisan view:clear

thanks
i fix the type problem

but still didnt work
i get this error
Undefined variable: panel_menus

and ity to the commend Undefined variable: panel_menus

didnt work :confused:

i cant pass a global var to livewire component directly

Try to pass it like so

@livewire('panel.buildit', ['panel_menus' => $panel_menus])

and see if it works.

thanks but still didnt work

Undefined variable: panel_menus

because in the web.php page its didn’t know that var panel_menus

Alright,
See this Video from Coders tape it may help you and if not let me now

I am getting something very similar in my local laravel homestead setup. I just installed a clean copy of Laravel 8/Jetstream with Livewire.

I am trying to pass data from my livewire component into the livewire blade template and I get “undefined variable errors” on render. The view loads correctly when I hard code HTML in it. I am at the point of just trying to just pass test text in a name variable like in the very first screencast available on this site. There has to be a configuration somewhere I am missing.

I am not using an interim blade template or laravel controller. It loads straight from the livewire component render function to the livewire blade template.

Component Code:

public function render()
{
return view(‘livewire.project-list’ , [
‘name’ => ‘I suck at this’
]);
}

Livewire Blade ‘project-list.blade.php’ - This extends my layouts.app template (‘app.blade.php’)

<x-app-layout>
   <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
           Project Overview
        </h2>
    </x-slot>
    <div class="py-12">
        <div class=" mx-auto sm:px-6 lg:px-8">
            <p> Testing this and it doesn't work </p>
            {{ $name }}
        </div>
    </div>
</x-app-layout>