简体   繁体   English

Laravel 5.8:parse_url() 期望参数 1 是字符串,给定数组

[英]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.

相关问题 Laravel 5.8 - in_array 给我错误:'htmlspecialchars() 期望参数 1 是字符串,数组给定' - Laravel 5.8 - in_array give me error : 'htmlspecialchars() expects parameter 1 to be string, array given' strpos()期望参数1为字符串,给定Laravel数组 - strpos() expects parameter 1 to be string, array given Laravel Laravel-htmlentities()期望参数1为字符串,给定数组 - Laravel - htmlentities() expects parameter 1 to be string, array given Laravel htmlspecialchars()期望参数1为字符串,给定数组 - Laravel htmlspecialchars() expects parameter 1 to be string, array given Laravel:htmlentities()期望参数1为字符串,给定数组 - Laravel : htmlentities() expects parameter 1 to be string, array given htmlspecialchars()期望参数1为字符串,在Laravel中给出数组 - htmlspecialchars() expects parameter 1 to be string, array given in Laravel Laravel htmlentities()期望参数1为字符串,给定数组 - Laravel htmlentities() expects parameter 1 to be string, array given strtotime() 期望参数 1 是字符串,数组在 laravel 中给出 - strtotime() expects parameter 1 to be string, array given in laravel Laravel数组输入-htmlentities()期望参数1为字符串,给定数组 - Laravel array inputs - htmlentities() expects parameter 1 to be string, array given htmlspecialchars() 期望参数 1 是字符串,给定数组。 (laravel) - htmlspecialchars() expects parameter 1 to be string, array given. (laravel)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM