I have two pages that are almost identical. One shows a list of users, the other shows the same list, but with more detailed information. Therefore, I call two views that extend the same shell. However, Laravel complains that $ user is not defined in verbose.blade.php. I pass a view to $ users that seems to be available for content.blade.php, but the $ user created in the foreach loop does not seem to be available in verbose.blade.php.
verbose.blade.php
@extends('layout.content') @section('user') {{ dd($user) }} @endsection
nonverbose.blade.php
@extends('layout.content') @section('user') {{ dd($user) }} @endsection
content.blade.php
@extends('layout.app') @section('content') @foreach($users as $user) @yield('user') @endforeach @endsection
I also tried @yield('user', ['user' => $user])
How can I make $ user available in verbose.blade.php?
laravel laravel-5 blade
Votemike
source share