我正在試圖用Laravel製作這個小的CV類型配置文件,我遇到了這個問題,我不知道它應該如何解決,正確的方法。 在用戶配置文件中,我有一個類別,用戶可以添加工作經歷。顯然,用戶可以在他工作的地方添加多個地方。我使用模態來做這件事,它可以工作,我可以將它們存儲在數據庫中。編輯多條記錄
事情是,現在我想讓用戶能夠編輯他輸入的內容。所以,我做了一個編輯按鈕,觸發一個模式窗口,他可以編輯數據庫記錄。 我不知道的是我可以如何獲取記錄的特定ID,以便填充模式窗口,然後保存所有更改。
要,因爲我不知道我是否是很清晰總結這件事..
我在DB 3項爲每個條目工作經歷+ 3個編輯聯繫。 然後,該編輯鏈接應導致用戶可編輯它的特定條目的模式窗口。
編輯:
我到了一個點以下一些對你有幫助。但是之後,我再次卡住..
所以,我必須在用戶配置文件這一工作經歷,這裏是如何我顯示出來:
@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
正如你所看到的,我有一個隱藏的輸入從哪裏獲得就業的ID。現在,這個ID我都將它傳遞給模態窗口,我可以編輯記錄.. 我想將它傳遞給模態,以便我可以顯示當前值從數據庫中:
@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
這是我在想這樣做,但我不知道如何傳遞$ EMPLID ......在我返回輪廓視圖控制器,我試圖通過它像這樣:
$emplID = Input::get('emplID');
return view('user.profile', compact(['employment','emplID']));
但是,如果我的DD($ EMPLID)我得到空出於某種原因...
既然你沒有發佈任何代碼,沒有人可以給你一個具體的答案,但一般的想法是你在按鈕的某個地方存儲ID,你點擊打開模式,然後用它來提取你的信息需要。 – Samsquanch