LoginSignup
1
0

More than 5 years have passed since last update.

Laravel のweb.phpのResource指定でshowが動かなかった話

Posted at

Laravel のweb.phpのResource指定でshowが動かなかった話。

下記を読んで、web.phpでresourceという指定をすると、
自動的に判別して、指定したControllerのindexやshowというfunctionへ飛ばしてくれると学んだ。
1.LaravelでRoute::resourceを使うときに気をつけること
2.Laravelのルーティング表

が、indexの処理は上手く動くのにshowの処理は上手く動かない。散々悩んだ結果が単純なコレでした↓

(誤)

        Route::resource('/student/', 'StudentController', ['only' => ['index','show']]);

(正)

        Route::resource('student', 'StudentController', ['only' => ['index','show']]);

前後にスラッシュを入れて記載する癖があったのですが、それが悪さをしていたようです。
resource指定をする際には文字のみで記載する良い様です。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0