0
votes

I want make search by parameters. But it shows i have mixing GET and POST methods. (Error message: MethodNotAllowedHttpException No message). Blade form by default have POST. i changed to GET. Route have GET method. Maybe you can see what i am doing wrong. This is my VIEW:

{!! Form::open([ 'action' => ['HomePageController@index', 'method' => 'get']]) !!}
<div class="container">
    <div class="col-xs-2 form-inline">
        {!! Form::label('city_id', trans('quickadmin.companies.fields.city').'', ['class' => 'control-label']) !!}
        {!! Form::select('city_id', $cities, old('city_id'), ['class' => 'form-control select2') !!}
    </div>

    <div class="col-xs-3 form-inline">
        {!! Form::label('categories', trans('quickadmin.companies.fields.categories').'', ['class' => 'control-label']) !!}
        {!! Form::select('categories', $categories, old('categories'), ['class' => 'form-control select2']) !!}
    </div>
    <div class="col-xs-3 form-inline">
        {!! Form::label('search', trans('quickadmin.companies.fields.name').'', ['class' => 'control-label']) !!}
        {!! Form::text('search', old('search'), ['class' => 'form-control', 'placeholder' => 'Search']) !!}
    </div>
    <div class="form-inline">
        <div class="col-xs-2">
            <button type="submit"
                    class="btn btn-primary">
                    Search
            </button>
        </div>
    </div>
</div>

{!! Form::close() !!}

My controller:

    public function index( Request $request)
{
    $cities = \App\City::get()->pluck('name', 'id')->prepend(trans('quickadmin.qa_please_select'), '');
    $categories = \App\Category::get()->pluck('name', 'id')->prepend(trans('quickadmin.qa_please_select'), '');
    $name = $request->input('city_id');
    $companies = \App\Company::All()->where('city_id', '=', $name);

    return view('table', compact('companies', $companies, 'cities', $cities, 'categories', $categories));

My route:

 Route::get('/', 'HomePageController@index');

Thank you for your help.

1
“Blade form by default have POST. i changed to GET.” - and of course you have checked the generated HTML code, to see if it actually says GET there, right …?CBroe

1 Answers

2
votes

There is a problem in the form open, try it like this :

{!! Form::open([ 'action' => 'HomePageController@index', 'method' => 'get']) !!}