禁止来自请求的响应。我真的不知道为什么。
我试图从多个输入插入数据库数据。单个输入正确存储。请求没有任何规则,因此错误不可能来自那里。
让我告诉你我的代码:
public function store(CreateRequest $request)
{
$l = new l();
$l->user_id = $request->input('registered');
$l->description = $request->input('descri');
$l->save();
$lastInsertedId= $l->id;
$input = $request->all();
$condition = $input['nym'];
foreach ($condition as $key => $condition) {
$le = new le();
$le->lid = $lastInsertedId;
$le->deman = $input['nym'][$key];
$le->dni = $input['dni'][$key];
$le->address = $input['address'][$key];
$le->contact_number = $input['contactnum'][$key];
$le->def = $input['abo'][$key];
$le->defe = $input['pro'][$key];
$le->created_at = date('Y-m-d h:i:s');
$le->save();
}
return redirect('blog')->with('ok', trans('back/blog.stored'));
}
多个输入的信息来自这里:
<tbody class="input_fields_wrap">
<tr>
<td><input type="text" name="nym[]" value="que" readonly="" style="outline:none;border:none;border-width:0px;"></td>
<td><input type="text" name="dni[]" value="funci" readonly="" style="outline:none;border:none;border-width:0px;"></td>
<td><input type="text" name="address[]" value="one" readonly="" style="outline:none;border:none;border-width:0px;"></td>
<td><input type="text" name="contactnum[]" value="13" readonly="" style="outline:none;border:none;border-width:0px;"></td>
<td><input type="text" name="abo[]" value="nem" readonly="" style="outline:none;border:none;border-width:0px;"></td>
<td><input type="text" name="pro[]" value="por" readonly=""</td>
<td><a class="remove_field">Eliminar</a></td>
</tr>
</tbody>
答案 0 :(得分:0)
我已经解决了这个问题。
我修改了添加可填充属性的模型:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Flight extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name'];
}