0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravel詳細画面作成

Posted at

詳細画面作成作った。

//コントローラー
	public function detail($id){
     //データベースから特定のIDを探してくる
		$posts = Post::find($id); 
		
		return view('posts.details', compact('posts'));
     //変数postsをdetails.blade.phpに送る
	}
//details.blade.php
 <a href="{{ route('posts.detail', ['id'=>$posts->id]) }}">応募する</a>

コントローラーから受け取った$posts変数の中にあるidをさらにweb.phpに送るため新しくid変数を作って代入。

//web.php
Route::get('/posts/details/{id}', 'PostController@detail')->name('posts.detail');

idを受けっとて{id}の中に入る。

流れは理解した。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?