Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我应该如何使用复选框声明控制器?_Php_Html_Laravel - Fatal编程技术网

Php 我应该如何使用复选框声明控制器?

Php 我应该如何使用复选框声明控制器?,php,html,laravel,Php,Html,Laravel,在这种情况下,如何使用复选框声明控制器 控制器: return User::create([ 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'usertype' => $data['usertype'], 'email' => $data['email'], 'password' => Hash::make($data['password

在这种情况下,如何使用复选框声明控制器

控制器:

return User::create([
    'firstname' => $data['firstname'],
    'lastname' => $data['lastname'],
    'usertype' => $data['usertype'],
    'email' => $data['email'],
    'password' => Hash::make($data['password']),
]);
代码:

<div class="form-group{{ $errors->has('usertype') ? ' has-danger' : '' }}">
    <div class="d-flex justify-content-center" >
        <div class="custom-control custom-radio custom-control-inline">
            <input type="radio" id="customRadioInline1" name="usertype" value="mokytojas" class="custom-control-input" required autofocus>
            <label class="custom-control-label" for="customRadioInline1">Mokytojas</label>
        </div>
        <div class="custom-control custom-radio custom-control-inline">
            <input type="radio" id="customRadioInline2" name="usertype" value ="paskaitu_lektorius" class="custom-control-input" >
            <label class="custom-control-label" for="customRadioInline2">Paskaitų lektorius</label>
        </div>
    </div>
</div>

莫基托哈斯
帕斯凯特·勒克托里厄斯

我想,或者会给你一些关于如何做的基本信息。我建议您在发布问题之前进行研究。

“使用复选框声明控制器”这是什么意思?哪个复选框?我正在使用laravel中的复选框,我想将其值发送到数据库,而您不知道如何/在何处执行此操作?与其他字段一样,将其添加到
User::create()
方法中的数组中。你试过什么,什么不起作用?您是否有错误?表单会在请求时发送true或false,因此您应该希望背面有一个布尔值-end@kerbholz好的,您可以看到有两个复选框,我希望数据库能够获得选中复选框的值。我只是不知道如何在控制器中编写代码。