Get jQuery post array values in laravel

Using j Query post some data are posting. Firebug console Post are given below. How can I get tags[] result in Laravel controller page. Please check my laravel code below, $request->tags result is not getting some errors are showing "preg_replace(): Parameter mismatch, pattern is a string while replacement is an array". Please help me to solve this issue.

Fire bug console

createdby    1
tagcategoryid   1
tags[]  Music
tags[]  Reading
tags[]  test
tags[]  test1
tags[]  test2
tags[]  test3

Laravel Code

public function store(InterestRequest $request)
    {
        $tag = new Tag;
        $tag->tagcategory_id  = $request->tagcategoryid;
        $tag->title_de        = $request->tags;
        $tag->title_en        = $request->tags;
        $tag->suggestion      = 'no';
        $tag->created_by      = $request->createdby;
        $tag->save();
    }


ANSWERS:


Your $request->tags post value is an array. And your are trying to set a string field type with an array. You have to loop through your tags in this case.

Probably this will solve your proplem:

public function store(InterestRequest $request)
{
    foreach($request->input('tags') as $tag) {
       Tag::create(array(
           'tagcategory_id' => $request->input('tagcategoryid'),
           'title_de'       => $tag,
           'title_en'       => $tag,
           'suggestion'     => 'no';
           'created_by'     => $request->input('createdby'),
       ))
    }
}

I have applied foreach. It works for me.

public function store(InterestRequest $request)
    {
        foreach(Input::get('tags') as $tags) {
            $tag = new Tag;
            $tag->tagcategory_id = $request->tagcategoryid;
            $tag->title_de = $tags;
            $tag->title_en = $tags;
            $tag->suggestion = 'no';
            $tag->created_by = $request->createdby;
            $tag->save();
        }
    }


 MORE:


 ? Laravel ajax 404 not found error
 ? Laravel unisharp file manager combine file and image manager
 ? Laravel unisharp file manager combine file and image manager
 ? Laravel unisharp file manager combine file and image manager
 ? laravel file manager doesn't show uploaded images
 ? Laravel 5 image resize
 ? TinyMCE Image Upload with Laravel, without File Manager
 ? Laravel file manager illegal offset type
 ? Laravel file manager illegal offset type
 ? Laravel file manager illegal offset type