/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // //$router->model('genre', 'Unicorn\Genre'); $router->bind('genre', function ($id) { return \Unicorn\Genre::with('albums')->where('id', $id)->first(); }); parent::boot($router); }
public function getAlbumsFor($genre) { return Genre::with('albums')->where('name', $genre)->first(); }