Well clearly enough you are not giving an instance of userBookings here
$bookingRequests=Auth::user()->BookingRequest();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
line 41 in searchController:
$bookingRequests=Auth::user()->BookingRequest();
User.php (Model):
public function bookings() {
return $this->hasMany('App\Models\Bookings');
}
public function BookingRequest(userBookings $userBookings)
{
return (bool)$this->bookings()->where('email',$userBookings->email)
->count();
}
The view:
@if(Auth::user()->BookingRequest($Userbookings))
<a href="#" class="btn btn-primary" data-toggle="modal" data-
target="#bookingModal">Show Number</a>
@else
<a href="#" class="btn btn-primary" data-toggle="modal" data-
target="#bookingModal">Book Me</a>
@endif
Hope this is enough detail
Yes, because $Employees is a collection, and not a single instance, so there is no $Employees->phone property. It might be a collection (array) containing a single model, but it's still a collection and not a single model. You'd have to use $Employees->first()->phone to grab the phone property from the first model instance in the collection and access the phone property on it, or loop through the collection of $Employees or something.
Do a dd($Employees); after you query it and check the output. It's an array of result(s). Not a single class with properties.
dd($Employees->getEmployeeMobile());
That would only work if $Employees is an instance of a single model instance. It's not.
Please or to participate in this conversation.