Reputation: 33
public function boot(Router $router)
{
parent::boot($router);
$router->model('article','App\article');
}
Route::resource('article','articleController');
public function show(Article $article)
{
/*$article=Article::find($id);*/
if(!$article){
abort(404);
}
return view('article.show ',compact('article'));
Declaration of App\Providers\RouteServiceProvider::boot(App\Providers\Router $router) should be compatible with Illuminate\Foundation\Support\Providers\RouteServiceProvider::boot()
Upvotes: 1
Views: 57
Reputation: 3529
Your issue comes from PHP inheritance. When you override a method, you have to keep the same signature than the parent method (except for __construct
). The boot
method of Laravel service provider is called through the container, so you can use Dependency Injection, but not in this case because App\Providers\RouteServiceProvider
inherits from another service provider which already has a boot
method defined.
In your case, you need to remove the Router from the signature and retrieve it from the method content thanks to
$router = $this->app['router'];
Upvotes: 3