我正在跟踪一些代码,每次尝试向用户显示帖子时,它都会手动将用户 ID 传递到 url,例如“http://127.0.0.1:8000/home/1”。如何在不输入 url 的情况下完成此操作
首页.blade.php
@foreach($user->posts as $post)
<div class="col-4">
<img src="/storage/{{$post->image}}" class="w-30" alt="">
</div>
路线
Route::get('/home/{user}', 'HomeController@index')->name('home');
家庭控制器
public function index(User $user)
{
//
return view('home', compact('user'));
}
Cats萌萌
郎朗坤
largeQ
慕莱坞森