gpt4 book ai didi

php - laravel 5.4 中更新数据时 $request->get() 未获取表单值

转载 作者:行者123 更新时间:2023-11-29 18:20:16 25 4
gpt4 key购买 nike

我正在尝试仅更新“business_account”表中的一列。我尝试了如下操作,当尝试将表单值获取到我的“packPurchasedMembers” Controller 函数时,我得到了空值。获得预期结果的正确代码应该是什么。

 Route::group(['prefix' => 'super', 'middleware' => 'super', 'as' => 'super.'], function () {
Route::post('verify-account', array('as' => 'verify-account', 'uses' => 'packPurchasedMembers@postVerifyAccount'));});

我的 Controller -

    public function postVerifyAccount(Request $request){            
$uid = $request->get('userid');
$verfiy = $request->get('verification');
DB::table('business_account')
->where('user_id', $uid)
->update(['verified' => $verfiy]);}

我的表格 -

              <div class="pull-left">
<h4>Verify Account</h4>
@foreach ($verification as $verify)
<form action="{{ url('super/verify-account') }}" method="POST">
{{ csrf_field() }}
<input type="hidden" name="userid" value="<?php echo $uid; ?>" />

<input type="radio" id="reinv1" name="verification" value="0"
<?php if ($verify->verified == '0') echo 'checked' ?> >
<label for="reinv1"> Not Verified</label>
<input type="radio" id="reinv2" name="verification" value="1"
<?php if ($verify->verified == '1') echo 'checked' ?> >
<label for="reinv2"> Verified</label>
<button type="submit" class="btn btn-success" value="Submit">Submit</button>
</form>
@endforeach
</div>

最佳答案

请使用以下函数检索输入值

public function postVerifyAccount(Request $request){            
$uid = $request->input('userid');
$verfiy = $request->input('verification');
DB::table('business_account')
->where('user_id', $uid)
->update(['verified' => $verfiy]);
}

关于php - laravel 5.4 中更新数据时 $request->get() 未获取表单值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46650966/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com