Francisunoxx Francisunoxx - 10 months ago 260
PHP Question

Grammar::parameterize() must be of the type array

I got this error

Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given,

when I tried add
in my View using select form. But when I removed it I didn't get any error. I'm just trying to input a multiple value in my select list. Do I need to use
for this?


<div class = "form-group {{ $errors->has('approver') ? ' has-error' : '' }}">

<label for = "approver" class = "control-label">Approver:</label>

<select name = "approver[]" multiple class = "form-control select2-multi">

@foreach ($approver as $list)
<option value = "{{ $list->id }}">{{ $list->username }}</option>


@if ($errors->has('approver'))
<span class = "help-block">{{ $errors->first('approver') }}</span>



public function getDocuments()
$approver = DB::table('users')->where('id', '!=', Auth::id())->get();

return view ('document.create')->with('approver', $approver);

public function postDocuments(Request $request)

'title' => 'required|regex:/(^[A-Za-z0-9 ]+$)+/|max:255',
'content' => 'required',
'category' => 'required',
'recipient' => 'required',
'approver' => 'required',

$document = new Document();
$approve = new Approve();
$user = Auth::user();
//Request in the form
$document->title = $request->title;
$document->content = $request->content;
$document->category_id = $request->category;
$approve->approver_id = $request->approver;






I die and dump the
variable and gives a array of value.


Also die and dump the
As you can see here I input the id of 4 and 5 in my select list.



Ok, your issue is that you're trying to save an array as a singular value where you need to iterate over the approvers instead.

Change your controller logic around to this:

foreach ($request->approver as $approver) {
    $approve              = new Approve();
    $approve->approver_id = $approver;