Level 75
$booking->user is null in some cases.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have a problem with my images. Why show this error? Controller:
public function allTimeAppointment()
{
$bookings = Booking::latest()->paginate(20);
return view('admin.patientlist.index', compact('bookings'));
}
HTML:
<tbody>
@forelse($bookings as $key=>$booking)
<tr>
<th scope="row">{{$key+1}}</th>
<td><img src="/profile/{{$booking->user->image}}" width="80" style="border-radius: 50%;"></td>
<td>{{$booking->date}}</td>
<td>{{$booking->user->name}}</td>
<td>{{$booking->user->email}}</td>
<td>{{$booking->user->phone_number}}</td>
<td>{{$booking->user->gender}}</td>
<td>{{$booking->time}}</td>
<td>{{$booking->doctor->name}}</td>
<td>
@if($booking->status==0)
<a href="{{route('update.status', [$booking->id])}}"><button class="btn btn-primary" style="white-space: nowrap;">Pending</button></a>
@else
<a href="{{route('update.status', [$booking->id])}}"><button class="btn btn-success" style="white-space: nowrap;">Checked</button></a>
@endif
</td>
</tr>
@empty
<td>You have no any appointments</td>
@endforelse
</tbody>
@unk Look to the database, column user_id is null somewhere in bookings table.
Please or to participate in this conversation.