Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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
String 对象类无法';不能转换为字符串Laravel 5_String_Laravel_Laravel 5_Eloquent - Fatal编程技术网

String 对象类无法';不能转换为字符串Laravel 5

String 对象类无法';不能转换为字符串Laravel 5,string,laravel,laravel-5,eloquent,String,Laravel,Laravel 5,Eloquent,当我返回控制器的请求时,我得到: {“员工”:“3”,“原因”:“普通” 原因”、“请求”:“5000”、“每付500”、“月到月支付”:“2”、“发布日期”:“2018-01-31”} 在我的create函数中,我得到以下错误: 类Symfony\Component\HttpFoundation\ParameterBag的对象无法转换为字符串 这是我的密码: CashAdvance::create([ 'emp_id' => $request->emplo

当我返回控制器的请求时,我得到:

{“员工”:“3”,“原因”:“普通” 原因”、“请求”:“5000”、“每付500”、“月到月支付”:“2”、“发布日期”:“2018-01-31”}

在我的create函数中,我得到以下错误:

类Symfony\Component\HttpFoundation\ParameterBag的对象无法转换为字符串

这是我的密码:

     CashAdvance::create([
        'emp_id' => $request->employees,
        'reason' => $request->reason,
        'request' => $request->request,
        'ded_per_pay' => $request->ded_per_pay,
        'date_issued' => $request->date_issued,
        'months_to_pay' => $request->months_to_pay
    ]);

是什么导致了这个问题???

这真的很有趣。我在中查看了一下,似乎请求对象有一个参数
Request
。这意味着当您调用
$request->request
时,您将从
$request
获取参数包

要解决此问题,您可以使用以下方法:

$myRequest=$request->input('request')

但我强烈建议您将
request
重命名为不会在项目后期混淆您自己/其他开发人员的名称,并保留这些特殊命名变量的实际含义

dd($request->request)输出
参数包
类的对象,而我们希望在表中保存一个字符串。改用
$request->get('request')