mardi 9 février 2021

Sharing variable to laravel layouts

I need to share variable to standart layout.app, but when i try to do it-the variable in blade is undefined. There is the controller part:

public function SidebarOffice(){
    $facultys=Faculty::all();
      return view('layouts.app', compact('facultys'));
}

And the layout.app part

 @foreach($facultys as $faculty)
            <a class="dropdown-item" href="#"></a>
                @endforeach

I also saw a way with a View::share. Can it work out with him?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3tJTQHA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire