Your code looks correct! Can you try to clear your class cache by running
php artisan clear-compiled
I recommend you to work with lowercase variables, because this uppercase variable is really unreadable and annoying to me :P
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi
I have posted a few times, but i'm getting this weird error.
I have 3 methods in my Tenancy Model
//Helper method to clean up Tenancy/index
public function notInTenancy()
{
return $this->accepted == 0 && $this->request_sent == 0;
}
public function hasRequestPending()
{
return $this->accepted == 0 && $this->request_sent == 1;
}
public function inTenancy()
{
return $this->accepted == 1 && $this->request_sent == 0;
}
hasRequestPending is not being recognized in the view, but the other two are. My error is
Method hasRequestPending does not exist. (View:
The methods are being passed in the controller via the $Tenancy variable
public function index($id){
$user = User::where('id', $id)->first();
$Tenancy = Tenancy::where('tenant_id', Auth::id())->get();
return view('/pages/account/index', compact('user', 'Tenancy'));
}
In my views they're being called like so
@if(Auth::user()->id == $user->id)
{{--
If the user signed in isn't the owner of this profile.
Do not show these buttons that control accept/reject/end
--}}
@if(Auth::user()->id == $user->id)
{{--
If the request has been sent but hasn't been accepted.
Give the option to accept and reject.
This updates the values in DB.
--}}
@if($Tenancy->hasRequestPending())
<form method="POST" action="/account/tenancy/{{$user->id}}/accept">
{{ csrf_field() }}
<input type="submit" class="btn btn-primary" value="Accept Request">
</form>
<form method="POST" action="/account/tenancy/{{$user->id}}/reject">
{{ csrf_field() }}
<input type="submit" class="btn btn-warning" value="Reject Request">
</form>
<!--
If the request has been accepted.
Show button to end the tenancy,
and property details
-->
@elseif($Tenancy->inTenancy())
<form method="POST" action="/account/tenancy/{{$user->id}}/end">
{{ csrf_field() }}
<input type="submit" class="btn btn-primary" value="End Tenancy">
</form>
<h5>Currently in Tenancy with {{$Tenancy->landlord_name}}</h5>
<h5>Your property is {{$Tenancy->property_address}}</h5>
@endif <!-- End of current user vs this user-->
@endif <!-- Initial If-->
The first method and third method are recognized, but number 2, is not.
Please or to participate in this conversation.