mardi 21 juin 2016

Error in passing argument to a controller function in laravel

I am trying to pass a variable $id to Controller function in routes file.

Following are the snippets from the respective files:

Routes.php

Route::get('/news-post/{$id}', 'BlogController@getPost');

BlogController.php

public function getPost($id)
    {
            $post = \App\blog::find($id);
            if($post == NULL){
                App::abort(404);
            }
            return View('webpages.news-post',['title'=>$post['title'],'post'=>$post]);
    }

I am getting a NotFoundHttpException in RouteCollection.php line 161:

I have tried searching for the reason but unable to find any.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire