From b534bc860752862fe7de9db26b88123f76648752 Mon Sep 17 00:00:00 2001 From: Ashraf Monshi Date: Thu, 1 Sep 2022 02:18:17 +0300 Subject: [PATCH] remove RouteKeyName slug --- routes/web.php | 2 +- src/Http/Livewire/Post.php | 6 +++--- src/Models/Post.php | 5 ----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/routes/web.php b/routes/web.php index 74e81cd..a465e49 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,7 +10,7 @@ ->middleware(config('zeus-sky.middleware')) ->group(function () { Route::get('/', Posts::class)->name('blogs'); - Route::get(config('zeus-sky.post_uri_prefix').'/{post:slug}', Post::class)->name('post'); + Route::get(config('zeus-sky.post_uri_prefix').'/{slug}', Post::class)->name('post'); Route::get(config('zeus-sky.page_uri_prefix').'/{slug}', Page::class)->name('page'); Route::get('{type}/{slug}', Tags::class)->name('tags'); diff --git a/src/Http/Livewire/Post.php b/src/Http/Livewire/Post.php index 0f452fb..943a919 100644 --- a/src/Http/Livewire/Post.php +++ b/src/Http/Livewire/Post.php @@ -7,11 +7,11 @@ class Post extends Component { - public postModel $post; + public $post; - public function mount(postModel $post) + public function mount($slug) { - $this->post = $post; + $this->post = postModel::whereSlug($slug)->firstOrFail();; } public function render() diff --git a/src/Models/Post.php b/src/Models/Post.php index fd85b1d..ba3dff0 100644 --- a/src/Models/Post.php +++ b/src/Models/Post.php @@ -51,11 +51,6 @@ protected static function newFactory() return PostFactory::new(); } - public function getRouteKeyName() - { - return 'slug'; - } - public function statusDesc(): string { $PostStatus = PostStatus::where('name', $this->status)->first();