skip to Main Content

I’m trying to use @include. But i got this error : Undefined variable: bookOther (View: /home/infinitr/pinus.infinitree.eco/modules/Tour/Views/frontend/guest_list.blade.php)

How can i fix it?

The Controller :

public function guests_list($id){
            $booking = Booking::where('id', $id)->first();
            $bookOther = BookOther::where('booking_id', '=', $booking->id)->get();
            
            return view('Tour::frontend.guest_list', ['booking'=>$booking, 'bookOther'=>$bookOther, 'layout'=>'guest_list']);
            
        }

The Route :

Route::get('/guest_list/{id}', 'ModulesTourControllersTourController@guests_list')->name('guest_list');

The blade :

<div id="booking-customer-{{$booking->id}}" class="tab-pane fade"><br>
 @include('Tour::frontend.guest_list')
</div>

2

Answers


  1. You can try to change:

    return view('Tour::frontend.guest_list', ['booking'=>$booking, 'bookOther'=>$bookOther, 'layout'=>'guest_list']);
    

    To this:

    return view('Tour::frontend.guest_list', compact('booking','bookOther', 'layout');
    
    Login or Signup to reply.
  2. Try passing the variable in the @include

    @include('Tour::frontend.guest_list',[
        'bookOther' => $bookOther,
    ])
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search