0

I have a search form that is sending a GET request to the method that it is using to view the form:

                <form class="form-horizontal" method="GET" action="{{ route('LoggedIn.StudentModule.StudentHomeWork.index') }}">
                    <div class="form-group form-group-sm">
                        <div class="col-sm-3">
                            <input type="text" name="inputdate" class="form-control datepicker" placeholder="Date" >
                        </div>
                        <div class="col-sm-2">
                            <button class="btn btn-primary btn-sm btn-block" type="submit">
                                <i class="fa fa-search" aria-hidden="true"></i>
                                Search 
                            </button>
                        </div>
                    </div>
                </form>

And the route:

Route::group(array(
    'middleware' => 'auth',
    'prefix' => '!',
    'namespace' => 'LoggedIn',
    'as' => 'LoggedIn.',
), function() {

    .................

    Route::group(array(
        'prefix' => 'StudentModule',
        'namespace' => 'StudentModule',
        'as' => 'StudentModule.'
    ), function () {

        ............

        Route::group(array(
            'prefix' => 'StudentHomeWork',
            'as' => 'StudentHomeWork.',
        ), function () {

            Route::get('/', array(
                'as' => 'index',
                'uses' => 'StudentHomeWorkController@index'
            ));
        });

    ..................

    });

    ...............
});

And my controller:

public function index()
{
    $searchParam = request('inputdate') ? request('inputdate') : date('Y-m-d');

    echo $searchParam; // this is showing no data
}

The problem is, i couldn't get the data from submitted form. I have used every option that i found in stackoverflow but couldn't get the data. Can anyone point me out what i am missing! My laravel version is 5.1

Note: I am using this method in Laravel 5.8 + 6. Which is working just fine

Alauddin Ahmed
  • 1,128
  • 2
  • 14
  • 34

1 Answers1

0

Try This How To Pass GET Parameters To Laravel From With GET Method ? Route::get('any', ['as' => 'index', 'uses' => 'StudentHomeWorkController@index']); Then Controller

public function index(){
    $searchParam = Input::get('category', 'default category');
}

Form:

{{ Form::open(['route' => 'any', 'method' => 'GET'])}}
    <input type="text" name="inputdate"/>
    {{ Form::submit('submit') }}
{{ Form::close() }}

There Also various method... Change it as your need.. You can also pass it in url like: Route::get('any/{data}','StudentHomeWorkController@index')->name('something); Controller:

public function index($data){
    print_r($data);
}

Hope it will help

void
  • 915
  • 8
  • 20