Is your view working without @include ?
Nov 23, 2022
6
Level 1
Laravel : @include
Hello, this is my first time using @include in laravel. When i'm trying to using it, i got this error message :
Undefined variable: bookOther (View: /home/infinitr/pinus.infinitree.eco/modules/Tour/Views/frontend/guest_list.blade.php)
How can i fix this?? 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 detail-modal blade :
<div class="tab-pane fade"><br>
@include ('Tour::frontend/guest_list')
</div>
The guest_list blade :
<h2 class="title-bar no-border-bottom">
{{__("Booking History")}}
</h2>
<div class="card-body">
<table class="table">
<thead>
<tr>
<th scope="col">Booking ID : {{$booking->id}}</th>
</tr>
</thead>
<tbody>
@foreach ($bookOther as $book)
<tr>
<td>{{$book->id}}</td>
<td>{{$book->booking_id}}</td>
<td>{{$book->user_id}}</td>
<td>{{$book->other_emails}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
Please or to participate in this conversation.