diff --git a/app/Livewire/BlogView.php b/app/Livewire/BlogView.php index 5297b54..59cbee1 100644 --- a/app/Livewire/BlogView.php +++ b/app/Livewire/BlogView.php @@ -2,6 +2,7 @@ namespace App\Livewire; +use App\Models\Blog; use Illuminate\View\View; use Livewire\Component; @@ -9,13 +10,13 @@ class BlogView extends Component { public $blog; - public function mount($blog): void + public function mount($slug): void { - $this->blog = $blog; + $this->blog = Blog::with(['user', 'images'])->where('slug', $slug)->first(); } public function render(): View { - return view('blogs.show')->layout('blogs.layout'); + return view('blogs.show')->layout('layouts.guest'); } } diff --git a/resources/views/livewire/blog-renderer.blade.php b/resources/views/livewire/blog-renderer.blade.php index d2c4659..8f1bb56 100644 --- a/resources/views/livewire/blog-renderer.blade.php +++ b/resources/views/livewire/blog-renderer.blade.php @@ -9,7 +9,7 @@
{!! Str::limit($blog->content, 300) !!}
- Read More + Read More @empty diff --git a/routes/web.php b/routes/web.php index b6bb91b..693d63e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use App\Livewire\BlogMaker; use App\Livewire\AutoOrderCreate; use App\Livewire\BlogRenderer; +use App\Livewire\BlogView; use App\Livewire\EditProfile; use App\Livewire\ManageUsers; use App\Livewire\OrderCreate; @@ -73,9 +74,7 @@ Route::post('/newsletter/subscribe', [PagesController::class, 'subscribe'])->name('newsletter.subscribe'); Route::get('/blog', BlogRenderer::class)->name('blog'); -Route::get('/blogs/{blog:slug}', function (Blog $blog) { - return view('blogs.show', compact('blog')); -})->name('blog.show'); +Route::get('/blogs/{slug}', BlogView::class)->name('blog.show'); require __DIR__.'/auth.php';