refactoring routes
This commit is contained in:
parent
67c193fbc9
commit
94002bc593
@ -47,7 +47,7 @@ class PostController extends Controller implements HasMiddleware
|
||||
return redirect()->route("posts.index", auth()->user()->username);
|
||||
}
|
||||
|
||||
public function show(Post $post)
|
||||
public function show(User $user, Post $post)
|
||||
{
|
||||
return view("posts.show", [
|
||||
"post" => $post
|
||||
|
@ -41,7 +41,7 @@
|
||||
<div class="grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
|
||||
@foreach ($posts as $post)
|
||||
<div>
|
||||
<a href="{{ route('posts.show', $post) }}">
|
||||
<a href="{{ route('posts.show', ['post' => $post, 'user' => $user]) }}">
|
||||
<img src="{{ asset('uploads') . '/' . $post->image }}" alt="{{ $post->title }}">
|
||||
</a>
|
||||
</div>
|
||||
|
@ -22,6 +22,6 @@ Route::post("/logout", [LogoutController::class, "store"])->name("logout");
|
||||
Route::get("/{user:username}", [PostController::class, "index"])->name("posts.index");
|
||||
Route::get("/posts/create", [PostController::class, "create"])->name("posts.create");
|
||||
Route::post("/posts", [PostController::class, "store"])->name("posts.store");
|
||||
Route::get("/posts/{post}", [PostController::class, "show"])->name("posts.show");
|
||||
Route::get("/{user:username}/posts/{post}", [PostController::class, "show"])->name("posts.show");
|
||||
|
||||
Route::post("/images", [ImageController::class, "store"])->name("images.store");
|
||||
|
Loading…
x
Reference in New Issue
Block a user