I'm trying to make this small CV type profile with Laravel and I encountered this problem that I'm not sure how it should be resolved, the correct way. In the user profile, I have a category where the user can add Employment History. Obviously, a user can add multiple places where he worked. I do this using modals and it works, I can store them in the database.
The thing is, now I want the user to be able to edit what he entered. So, I made an edit button which triggers a modal window where he can edit the database record. What I don't know is how I can take the specific id of the record so I can populate the modal window and then save any changes.
To sum this up because I'm not sure if I was clear enough..
I have 3 entries in DB for Employment History + 3 Edit links for each entry. Then, that Edit link should lead to a modal window of the specific entry where the user can edit it.
EDIT:
I got to a point after following some of your help.. However, I'm stuck again..
So, I have this employment history in the user profile, here's how I display it:
@foreach ($employment as $empl)
<input type="hidden" name="emplID" value="{{ $empl->id }}">
<button data-toggle="modal" data-target="#edit-empl" href="#edit-empl" class="btn btn-default" type="button" name="editbtn">Edit</button>
<h3 class="profile-subtitle">{{ $empl->company }}</h3>
<p class="profile-text subtitle-desc">{{ $empl->parseDate($empl->from) }} - {{ $empl->parseDate($empl->to) }}</p>
@endforeach
As you can see, I have a hidden input where I get the employment id.. Now, this id I have to pass it to the modal window where I can edit the records.. I want to pass it to the modal so I can display the current values from the database:
@foreach ($employment as $empl)
@if ($empl->id == $emplID)
<div class="form-group">
<label for="company">Company:</label>
<input type="text" name="company" value="{{ $empl->company }}">
</div>
<div class="form-group">
<label for="month">From:</label>
<input type="date" name="from" value="{{ $empl->from }}">
</div>
<div class="form-group">
<label for="to">To:</label>
<input type="date" name="to" value="{{ $empl->to }}">
</div>
@endif
@endforeach
This is how I was thinking to do so but I'm not sure how to pass that $emplID... In the controller where I return the profile view, I tried to pass it like this:
$emplID = Input::get('emplID');
return view('user.profile', compact(['employment','emplID']));
But if I dd($emplID) I'm getting null for some reason...