Link to / display title slug

Posted 4 years ago by christopher

I found a really cool package to handle slugs

https://github.com/cviebrock/eloquent-sluggable

So far it`s working. If i create a new Database entry the packages grabs the title and convert this to the slug and save it in the database.

Now my question: How can i link to a slug instead of using the ID ?

Normally i would display the entry as follows:

  Route::get('events/{id}', 'EventsController@show');

I tried

  Route::get('events/{slug}', 'EventsController@show');

In my Controller i have

   public function show($id)
  {
   return View::make('events.show');
   }

But this does not work. Does someone know how i can display to the Event via the slug ?

Please sign in or create an account to participate in this conversation.