I have posted here a few times, on various aspects about on application. It's a property app.
I have a Landlord, and Tenant profiles. In this scenario, I'm logged into a Landlord account. I'm currently viewing a prospective tenants profile. I click a button called "Start Tenancy" which redirected me to a from. I want to populate this form with the name of the tenant I just clicked on. How would I go about this?
Currently clicking this button sends me to a form, but I don't know to associate it with the user whose page I was just on. Is it as simple as using the id.
The controller that links to form
public function tenancyIndex(){
return view('/pages/account/tenancy/create');
}
Create form view.
<form action="#" method="POST">
<div class="row">
<div class="row mt-2">
<div class="col-md-6">
<label for="landlord-name">Landlord Name</label>
</div> <!-- ./col=6 -->
</div> <!-- ./ row-4-->
<div class="row">
<div class="col-md-6">
<select class="form-control" name="landlord-name">
<option >Landlord Name</option>
</select>
</div> <!-- ./ row 3-->
</div> <!-- ./col-3 -->
<div class="row mt-2">
<div class="col-md-6">
<label for="tenant-name">Tenant Name</label>
</div> <!-- ./col=6 -->
</div> <!-- ./ row-4-->
<div class="row">
<div class="col-md-6">
<select class="form-control" name="tenant-name">
<option>Tenant Name</option>
</select>
</div> <!-- ./ row 3-->
</div> <!-- ./col-3 -->
<button class="mt-2 btn btn-primary" type="submit">Create Watchlist</button>
</form> <!-- ./form -->
I have profiles set up already. I'm not sure if I should post that. This is a method in the same controller that opens up the profile page.
public function index($id){
//Authenticated different user types
//Sends Landlord and Tenant to appropiate pages
$user = User::where('id', $id)->first();
$properties = PropertyAdvert::where('user_id', $id)->get();
$property = WatchedProperties::all();
$Watchlists = Watchlists::where('user_id', Auth::id())->get();
$users = Auth::user();
$tenancies = $users->tenancies();
$tenancyRequests = $users->tenacyRequests();
return view('/pages/account/index', compact('properties', 'user', 'Watchlists', 'property', 'tenancyRequests', 'tenancies', 'Watchlists'));
}
The accounting view is then different depending on if you're a landlord or tenant.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2pEVlqX
via IFTTT
Aucun commentaire:
Enregistrer un commentaire