Laravel route url with query string

后端 未结 4 454
感动是毒
感动是毒 2021-02-02 07:59

On laravel 4 I could generate a url with query strings using the route() helper. But on 4.1 instead of:

$url = url(\'admin.events\', array(\'lang\' => \'en\')         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-02-02 08:30

    A simple way to do this, specially to use with jQuery Autocomplete, it's modify the Controller with a condition to check if has 'term' in the $request:

    (Controller file)

    public function list_for_autocomplete(Request $request)
    {
        if ($request->has('term')) {
            return YourModel::select('column_name as value')
                ->where('column_name', 'like', '%' . $request->input('term') . '%')
                ->get()
        }
    }
    

提交回复
热议问题