LoginSignup
0
1

More than 5 years have passed since last update.

Laravel チートシート ルーティング 編

Last updated at Posted at 2019-02-21

ルート一覧

php artisan route:list

ルートパラメータ

リクエストパラメータとの混同注意

強制

    Route::get('/book/detail/{id}', 'Admin\BookController@getBookDetail')
        ->name('book.detail')
        ->middleware('https');

任意

    Route::get('/book/detail/{id?}', 'Admin\BookController@getBookDetail')
        ->name('book.detail')
        ->middleware('https');

コントローラ例

    public function getBookDetail($id = null)
    {

        $book = Book::find($id)

        return view('book.detail', compact('book'))

    }

リンク例

    <a href="{{route('book.detail', $book->id)}}" >
0
1
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
0
1