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}', '\Modules\Tour\Controllers\TourController@guests_list')->name('guest_list');
The blade :
<div id="booking-customer-{{$booking->id}}" ><br>
@include('Tour::frontend.guest_list')
</div>
CodePudding user response:
Make sure variable is defined:
dd($bookOther); // against the ID
CodePudding user response:
Try passing the variable in the @include
@include('Tour::frontend.guest_list',[
'bookOther' => $bookOther,
])
CodePudding user response:
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');