0
我有一個users
表,其中我有一個column
名爲rank_id
。現在我想將所有用戶rank_id
更新爲2
,其中rank_id = 6
一次(單擊一個按鈕)。我怎樣才能做到這一點?到目前爲止,我曾嘗試:如何通過Laravel 5.2一次更新特定的列數據?
路線:
Route::post('/test/rankup2', array('as' => 'user.rank2.post', 'uses' => '[email protected]'));
TestController.php:
function RankUpgradeTwo(Request $request)
{
$memberAll = User::where('rank_id','=',6)->firstOrFail();
//dd($memberAll);
$memberAll->rank_id = '2';
$memberAll->save();
return Redirect::to('user/test')->with('message', 'Successfully Ugraded into Rank 2');
}
testScript.blade.php:
<form method="POST"
action="{{ route('user.rank2.post') }}"
class="form-horizontal stdform"
autocomplete="off"
enctype="multipart/form-data"
id="edit-form"
role="form"
{{--v-on:submit="submitChange" --}}
novalidate />
{{ csrf_field() }}
<div class="control-group action">
<button type="submit" name="submit" value="submit" id="submit" class="btn btn-blue btn-left">
Rank Up 2
</button>
</div>
{{ Form::close() }}
這顯示我成功的消息,但我沒有看到數據庫中的任何更新。提前致謝。
完美!...非常感謝。 –
@ChoncholMahmud去接受吧! –