[英]Laravel 5.8: parse_url() expects parameter 1 to be string, array given
I want to insert some data into the DB like this via Eloquent:我想通过 Eloquent 将一些数据插入到数据库中:
public function postDarkhast(Request $request)
{
RequestTable::create([
'course_name' => 1,
'course_start' => 2,
'course_end' => 3,
'course_sessions' => 4,
'course_time' => 5,
'course_members' => 6,
'course_mentor' => 7,
'course_samaneh' => 8,
]);
Session::flash('darkhastSubmitted','Request submitted');
return redirect()->back();
}
But I don't know why I get this error:但我不知道为什么会出现此错误:
parse_url() expects parameter 1 to be string, array given parse_url() 期望参数 1 是字符串,给定数组
I don't know where this parse_url()
comes from and the reason behind this error.我不知道这个
parse_url()
来自哪里以及这个错误背后的原因。
So if you know, please help me out solving this issue?所以如果你知道,请帮我解决这个问题?
Here is also the Model RequestTable
:这也是 Model
RequestTable
:
class RequestTable extends Model
{
protected $table = "requests";
protected $guarded = [];
}
And the fields of requests
table has this config: requests
表的字段具有以下配置:
varchar(191) utf8_general_ci NULL
UPDATE #1:更新#1:
I put the RequestTable::create([...]);
我把
RequestTable::create([...]);
in a Try.. Catch and this error return:在 Try.. Catch 中,此错误返回:
It looks like you are importing the Request
from Symfony's HttpFoundation
instead of Illuminate
.看起来您正在从 Symfony 的
HttpFoundation
而不是Illuminate
导入Request
。 Please try importing the Request at the top like: use Illuminate\Http\Request;
请尝试在顶部导入请求,例如:
use Illuminate\Http\Request;
. .
Looking at your error, I believe you are importing the Symfony\Component\HttpFoundation\Request
instead.查看您的错误,我相信您正在导入
Symfony\Component\HttpFoundation\Request
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.