php - 如何批量分配 laravel fillable

标签 php laravel

<form action="display" method="post">

<label>Details</label></br> 
<input type="radio" name="vishal" value="male">vishal</br>  
<input type="radio" name="vishal" value="female">male</br>  
<input type="radio" name="vishal" value="other">other</br>  

<input type="hidden" name="_token" value="xYj3n27EQNybQvY29mDrZxoYy3sGtbFTqfN8xeso">    

<label>Details</label></br> 
<input type="radio" name="rahul" value="male">rahul</br>    
<input type="radio" name="rahul" value="female">male</br>   
<input type="radio" name="rahul" value="other">other</br>   

<input type="hidden" name="_token" value="xYj3n27EQNybQvY29mDrZxoYy3sGtbFTqfN8xeso">    

<label>Details</label></br> 
<input type="radio" name="demo" value="male">demo</br>  
<input type="radio" name="demo" value="female">male</br>    
<input type="radio" name="demo" value="other">other</br>    

<input type="hidden" name="_token" value="xYj3n27EQNybQvY29mDrZxoYy3sGtbFTqfN8xeso">

<input type="submit" name="submit" value="submit">
</form>
  • 如何在不手动填写每个字段的情况下插入内容?
  • 我目前有以下protected $fillable = ['gender','vishal','rahul', 'demo'];
  • 但是我的字段有多个并且我无法为每个字段编写手动可填写参数
  • 如何在没有 $fillable 的情况下插入数据库?

最佳答案

找到需要使用的解决方案

YourModel:: forceCreate($request->all()); 

关于php - 如何批量分配 laravel fillable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40705254/

相关文章:

使用 UBL/不同命名空间读取 PHP simplexml

laravel - 在 Laravel 5.4 查询构建器中自动使用时间戳

php - Laravel @parent 不工作

php - file_get_contents 不起作用?

php - 拉维尔 : Load a view after posting

php - 用于 API 和非 API 使用的 Laravel 资源 Controller

arrays - 在 Laravel Controller 中创建数据数组

php - POST 方法的 Laravel + Vue + Axios 问题

php - homebrew-php 中缺少 PHP53 或 PHP54

php - 为什么文件权限不断变化?