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'));
App \ Providers \ RouteServiceProvider :: boot (App \ Providers \ Router $ router)에 대한 선언은 Illuminate \ Foundation \ Support \ Providers \ RouteServiceProvider :: boot ()와 호환되어야합니다.
귀하의 문제는 PHP 상속에서 비롯됩니다. 메서드를 재정의 할 때 부모 메서드와 동일한 서명을 유지해야합니다 (제외 __construct
). boot
Laravel 서비스 제공 업체 의 메소드는 컨테이너를 통해 호출되므로 Dependency Injection을 사용할 수 있지만이 경우에는 App\Providers\RouteServiceProvider
이미 boot
메소드가 정의 된 다른 서비스 제공 업체에서 상속 하기 때문에 사용할 수 없습니다 . 귀하의 경우에는 서명에서 라우터를 제거하고 다음 덕분에 메서드 콘텐츠에서 검색해야합니다.
$router = $this->app['router'];
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다