2023年9月22日解決済み

$index と {id} が対応しているのですか?

ユーザー

/MyBBS/resources/views/index.blade.php の、

 @forelse ($posts as $index => $post)
                <li>
                    <a href="{{ route('posts.show', $index) }}">
                        {{ $post }}
                    </a>
                </li>
            @empty
                <li>No posts yet!</li>
            @endforelse

の $index と、
/MyBBS/routes/web.php の、

Route::get('/posts/{id}', [PostController::class, 'show'])
    ->name('posts.show');

の {id} が対応しているというふうに理解しているのですが、正しいですか?

スタッフ

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?