I have two user types in my application. A landlord, and a tenant. Currently when a landlord is one a tenants page, they can see the start tenant button and thats it. If a request is sent, and I try to show that, the landlord can't see the message on the tenants page, but the tenant can see it in their page/
How to I allow the landlord to see the message the tenant can see.
This is the database row (fake data)
The controller code that renders the profiles is
public function index($id){
//Authenticated different user types
//Sends Landlord and Tenant to appropiate pages
$user = User::where('id', $id)->first();
//Allows landlords to see their relationship with tenants, and vice versa.
$landlordTenancies = Tenancy::all()->where('landlord_id', Auth::id());
$tenantTenancies = Tenancy::all()->where('tenant_id', Auth::id());
//Allows the attirbutes from the table to be access by correct landlord and tenant
$tenancy = Tenancy::where('tenant_id', Auth::id())->first();
$Tenancy = Tenancy::where('landlord_id', Auth::id())->first();
//Sends different use types to relevant view
if($user->userType == "Landlord"){
return view('/pages/account/landlord', compact('properties', 'user', 'Watchlists', 'property', 'landlordTenancies', 'Tenancy'));
}
else{
return view('/pages/account/tenant', compact('properties', 'user', 'Watchlists', 'property', 'tenantTenancies', 'tenancy'));
}
}
}
Tenant view page
div class="container">
<div class="row">
<div class="col-md-12">
@foreach($tenantTenancies as $tenancy)
<span class="lead"><strong>Landlord Name: </strong></span><br>
<span class="lead"><strong>Property Address: </strong></span><br>
@endforeach
@if(Auth::user()->id != $user->id)
@if($tenancy == null || $tenancy->accepted == 0 && $tenancy->request_sent != 1)
<a href="/account/tenancy//create" class="btn btn-primary">Start Tenancy</a>
@elseif($tenancy->request_sent === 1)
<span class="text-muted">You have a tenancy request</span>
@endif
@endif
@if(Auth::user()->id == $user->id)
@if($tenancy != null && $tenancy->accepted == 0 && $tenancy->request_sent == 1)
<form method="POST" action="/account/tenancy//accept">
<input type="submit" class="btn btn-primary" value="Accept Request">
</form>
<form method="POST" action="/account/tenancy//reject">
<input type="submit" class="btn btn-warning" value="Reject Request">
</form>
@elseif($tenancy != null && $tenancy->accepted == 1 && $tenancy->request_sent == 0)
<form method="POST" action="/account/tenancy//end">
<input type="submit" class="btn btn-primary" value="End Tenancy">
</form>
@endif
@endif
</div>
</div>
Landlord View Page
<div class="row text-center d-flex flex-wrap">
<div class="col-lg-12">
@foreach($landlordTenancies as $tenancy)
<span class="lead"><strong>Tenant Name: </strong></span><br>
<span class="lead"><strong>Property Address: </strong></span><br>
@endforeach
<h3>Your Active Adverts</h3>
<div class="row py-2">
@foreach ($properties as $property)
<div class="col-md-4 mb-4">
<a href="/property/">
<img class="list-image img-fluid" src="">
</a>
<p class="mt-2"></p>
</div>
@endforeach
</div> <!-- ./col -->
</div> <!-- ./row -->
</div> <!-- ./container -->
Currently when the landlord is on the tenant page, they can see this. Even if a request is sent, they don't see the message, request sent.
When the tenant is on the tenant and they see the message request sent as well as the accept/reject buttons.
I need the landlord to be able to see the request sent message, while on the tenants page, and for the tenant not to see it.
Any ideas
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HGaIdN
via IFTTT
Aucun commentaire:
Enregistrer un commentaire