routing to show posts
This commit is contained in:
parent
a9e4fa1e96
commit
67c193fbc9
@ -46,4 +46,11 @@ class PostController extends Controller implements HasMiddleware
|
||||
|
||||
return redirect()->route("posts.index", auth()->user()->username);
|
||||
}
|
||||
|
||||
public function show(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="#">
|
||||
<a href="{{ route('posts.show', $post) }}">
|
||||
<img src="{{ asset('uploads') . '/' . $post->image }}" alt="{{ $post->title }}">
|
||||
</a>
|
||||
</div>
|
||||
|
8
resources/views/posts/show.blade.php
Normal file
8
resources/views/posts/show.blade.php
Normal file
@ -0,0 +1,8 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title')
|
||||
{{ $post->title }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@endsection
|
@ -22,5 +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::post("/images", [ImageController::class, "store"])->name("images.store");
|
||||
|
Loading…
x
Reference in New Issue
Block a user