dimanche 4 mars 2018

cannot figure out how to add method to resource laravel 5

I'm trying to add methods to my resource in laravel 5.6. This is my web.php file:

Route::get('/home', 'HomeController@index')->name('home');
Route::get('/results', 'StudentsController@results');
Route::resource('student', 'StudentsController');

and here is (the important part) of my controller:

public function index()
    {
        return view('search');
    }

    public function results()
    {
        $search = \Request::get('search');

        $results = Student::where('last_name','like','%'.$search.'%')->get();

        return view('results')->with('results', $results);

    }

I'm trying to call the "results" function in the action on a form by doing but it's returning an eternal error of

Route [student.results] not defined.

I can do this exact syntax with all the other default crud functions in the controller. What am I doing wrong so that I can't call this new function. I have a feeling it's the wording of my route but I couldn't find anything that showed me exactly what to do. Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2H3YN4G
via IFTTT

Aucun commentaire:

Enregistrer un commentaire