Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

me10071990's avatar

Getting error like Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array,

Hey All,

I am about to done almost my 1st training demo project for job but somehow last error is coming, previously I posted the same question for this but it was not answered. Please help so can sort out error.

Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, null given, called in :\xampp\htdocs\testCER\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 87

0 likes
20 replies
Tray2's avatar

Show the code that generates the error.

me10071990's avatar

First Thanks for your reply @tray2 ...

Here is my controller...

                 public function store(Request $request)
{
  //  dd($request->all());
    $data = new past_events();
    $data->title = $request->title;
    $data->slug = $request->slug;
    $data->event_date = $request->event_date;
    $data->event_video_link = $request->event_video_link;
    $data->event_place_name = $request->event_place_name;
    $data->category_id = $request->category_id;

    if($request->hasFile('image'))
    {
        $image = request('image');
        $filename = time().$image->getClientOriginalName();
        $image->move(public_path().'uploads/past/',$filename);
        $data->image = $filename;
   }
    $data->save();

    $id = $data->id; // foreign_key

    foreach ($request->Featured as $key=>$file){
        $speaker=new past_event_speaker();
        $speaker->past_event_id = $id;
        $speaker->Featured = $request->Featured[$key];(this is for image)
        $speaker->speaker_name = $request->speaker_name[$key];
        $speaker->speaker_position = $request->speaker_position[$key];

        $speaker->save();
    }

    foreach ($request->Featured1 as $key=>$file){
        $session = new past_event_session();
        $session->past_event_id = $id;
        $session->Featured1 = $request->Featured1[$key];   (This is for image)
        $session->session_time = $request->session_time[$key];
        $session->event_session_name = $request->event_session_name[$key];
        $session->session_person_name = $request->session_person_name[$key];
        $session->session_person_topic = $request->session_person_topic[$key];
        $session->File =$request->File[$key];(This is for pdf file)

        $session->save();
    }
}
Tray2's avatar

And the complete error message?

slev1n's avatar
slev1n
Best Answer
Level 4

You trying to save arrays instead of string|int|whatever-else here:

$data->title = $request->title;
$data->slug = $request->slug;
$data->event_date = $request->event_date;
$data->event_video_link = $request->event_video_link;
$data->event_place_name = $request->event_place_name;
$data->category_id = $request->category_id;

Pass that values as text, or change __get from request way ($request->title[0])

upd. see your first screen - there are only arrays

1 like
me10071990's avatar

@slev1n , in title, slug,event_date,event_video_link,event_place_name and category_id are in first table where I not using array just passing single time value. and in another I am using array, so that it's showing. Thanks

slev1n's avatar

SHow dd($data->getAttributes()) output (put before $data->save())

upd. so it's helps?

Snapey's avatar

what @slev1n says.

Each of your variables is a single element array. My guess is that on a front end form you have for some reason added [] to every form name

eg name="title[]" so all your input elements are arrays

me10071990's avatar

@snapey , As title and all column store in single table so I am not using name="title[]" i have like name="title"..but still getting same error.

Snapey's avatar

so how do you get the data? How come they are all arrays?

me10071990's avatar

@snapey , no, For first table all are in simple form and for 2nd table and 3rd table they are in array.

me10071990's avatar

@snapey , @tray2 , @slev1n , Now data are submitting in simple form and also for array form for all 3 section , However, Image is showing NULL, and Featured1 has data like "C:\xampp\tmp\php4CD9.tmp" and For file "C:\xampp\tmp\php4CDA.tmp" and for Featured it's showing like "C:\xampp\tmp\php4CC7.tmp" in data base..Thanks to all

siangboon's avatar

all the error images you posted were showing all array...

probably you should show your form and model as well...

me10071990's avatar

Thanks @siangboon, Here is link for code..

1> controller->https://paste.ofcode.org/345CS7zgbDvT4uCdzgKtfcW

2>Create.blade.php->https://paste.ofcode.org/8eBxj7rD77GrnbEBYW7tNm

3> Model->past_event->https://paste.ofcode.org/6MtuQA7dnsu2wHWw4CivMZ

4>Model->past_event-speaker->https://paste.ofcode.org/agPLRm8t8tBTFdTtmLCzKq

5>Model->past_event-session->https://paste.ofcode.org/33T6nmH729w6tBtFL3m8SBK

Here is all code link so you can chech, only Image are showing in index, however, Featured , Featured1, File and slug is not working.

Tray2's avatar

To me it looks like this is the culprit

foreach ($request->Featured as $key=>$file){

Try changing to

foreach ($request('Featured') as $key=>$file){
me10071990's avatar

@tray2 , I changed with this logic , throwing error, Is it right to add multiple image (Featured)?

Please suggest in it.

Thanks

Tray2's avatar

Rigth or wrong hm. I would probably not do it that way and use a package that does it for me or maybe have a loop checking for multiple files. It depends on what you are trying to do.

I wolud suggest remove all the [] from your form and get that to work first then add it on the ones where you really need to send multiples.

I would probably use javascript to submit them one by one.

me10071990's avatar

@tray2 thanks, I did as you have suggested. However, only image problem. thanks

Please or to participate in this conversation.