I want to insert some data into the DB like this via 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
I don't know where this parse_url()
comes from and the reason behind this error.
So if you know, please help me out solving this issue?
Here is also the Model RequestTable
:
class RequestTable extends Model
{
protected $table = "requests";
protected $guarded = [];
}
And the fields of requests
table has this config:
varchar(191) utf8_general_ci NULL
UPDATE #1:
I put the RequestTable::create([...]);
in a Try.. Catch and this error return:
CodePudding user response:
It looks like you are importing theRequest
from Symfony's HttpFoundation
instead of Illuminate
. Please try importing the Request at the top like: use Illuminate\Http\Request;
.
Looking at your error, I believe you are importing the Symfony\Component\HttpFoundation\Request
instead.