====== 28 Laravel Voyager フロントページ用意 ====== https://devdojo.com/tutorials/working-with-voyager-on-the-front-end ===== Post ===== ==== 一覧ページ ==== Postのデータ一覧を表示するページ === 1.コントローラ === コントローラ作成 ※コントローラ内でテーブルを指定しない場合、同じ名前のテーブルを参照する。 php artisan make:model Post 下記ができる === 2.ルーティング === Route::get('/foo', function () { $posts = App\Post::all(); return view('home', compact('posts')); }); === 3.Viewを作成 === Homepage


@foreach($posts as $post) @endforeach
=== 4.ページ完成 === URL: http://hogehoge.com/foo 一覧のページが完成 {{:11_php:02_framework:01_laravel:post_1.png?400|}} ==== シングルページ ==== 個々のページへのアクセス === 1.ルーティング === Route::get('post/{slug}', function($slug){ $post = App\Post::where('slug', '=', $slug)->firstOrFail(); return view('post', compact('post')); }); === 2.View === {{ $post->title }}

{{ $post->title }}

{!! $post->body !!}

=== 3.ページ完成 === URL: http://hogehoge.com/post/yarr-post {{:11_php:02_framework:01_laravel:post_2.png?400|}} ===== Pages ===== === 1.コントローラ === php artisan make:model Pages 下記のコントローラが作成される === 2.ルーティング === Route::get('pages/{slug}', function($slug){ $pages = App\Pages::where('slug', '=', $slug)->firstOrFail(); return view('pages', compact('pages')); }); === 3.View === {{ $pages->title }}

{{ $pages->title }}

{!! $pages->body !!}

=== 4.完成 === http://hogehoge.com/pages/hello-world {{:11_php:02_framework:01_laravel:pages_01.png?400|}} {{tag>Laravel Voyager}}