From 804e43b02c14b6ce324114b3c9bead92ee39a190 Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe Date: Tue, 24 Oct 2023 14:09:35 +0300 Subject: [PATCH] fix projects edit is national fix show category page on articles --- .../Resources/Articles/ArticleResource.php | 3 +- app/Http/Controllers/ArticleController.php | 6 +++ .../Resources/Project/EditProjectResource.php | 2 +- app/Models/Article.php | 2 +- .../Pages/AdminOng/Projects/EditProject.vue | 45 +++++++++++++++++++ 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/app/Filament/Resources/Articles/ArticleResource.php b/app/Filament/Resources/Articles/ArticleResource.php index cb752fd4..5a148697 100644 --- a/app/Filament/Resources/Articles/ArticleResource.php +++ b/app/Filament/Resources/Articles/ArticleResource.php @@ -20,7 +20,6 @@ use Filament\Resources\Table; use Filament\Tables; use Filament\Tables\Columns\TextColumn; -use Filament\Tables\Filters\Layout; use Filament\Tables\Filters\SelectFilter; use FilamentTiptapEditor\TiptapEditor; @@ -50,6 +49,7 @@ public static function getPluralModelLabel(): string { return __('article.label.plural'); } + protected static function getNavigationBadge(): ?string { return (string) Article::count(); @@ -177,7 +177,6 @@ public static function table(Table $table): Table ]); } - public static function getPages(): array { return [ diff --git a/app/Http/Controllers/ArticleController.php b/app/Http/Controllers/ArticleController.php index e4af465c..4aa7eb15 100644 --- a/app/Http/Controllers/ArticleController.php +++ b/app/Http/Controllers/ArticleController.php @@ -45,6 +45,12 @@ public function category(ArticleCategory $category, Request $request): Response ->orderByDesc('id') ->paginate(5) ), + 'topArticles' => ArticleCardResource::collection( + Article::query() + ->wherePublished() + ->inRandomOrder() + ->limit(3) + ->get()) ]); } diff --git a/app/Http/Resources/Project/EditProjectResource.php b/app/Http/Resources/Project/EditProjectResource.php index 4398bb96..e2a25865 100644 --- a/app/Http/Resources/Project/EditProjectResource.php +++ b/app/Http/Resources/Project/EditProjectResource.php @@ -31,7 +31,6 @@ public function toArray(Request $request): array 'name' => $this->organization->name, 'id' => $this->organization->id, ], - 'is_national' => \boolval($this->is_national), 'beneficiaries' => $this->beneficiaries ?? '', 'start' => $this->start?->format('Y-m-d'), 'end' => $this->end?->format('Y-m-d'), @@ -40,6 +39,7 @@ public function toArray(Request $request): array 'reason_to_donate' => $this->reason_to_donate ?? '', 'accepting_volunteers' => $this->accepting_volunteers ? __('field.boolean.true') : __('field.boolean.false'), 'accepting_comments' => $this->accepting_comments ? __('field.boolean.true') : __('field.boolean.false'), + 'is_national' => $this->is_national ? __('field.boolean.true') : __('field.boolean.false'), 'videos' => empty($this->videos) ? [] : $this->videos, 'external_links' => empty($this->external_links) ? [] : $this->external_links, 'counties' => $this->counties->pluck('id')->toArray(), diff --git a/app/Models/Article.php b/app/Models/Article.php index 63ea9bae..c3b6cc2c 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -27,7 +27,7 @@ class Article extends Model implements HasMedia 'title', 'slug', 'content', - 'is_active', + 'is_published', 'article_category_id', 'author', ]; diff --git a/resources/js/Pages/AdminOng/Projects/EditProject.vue b/resources/js/Pages/AdminOng/Projects/EditProject.vue index f174e382..0bc833bc 100644 --- a/resources/js/Pages/AdminOng/Projects/EditProject.vue +++ b/resources/js/Pages/AdminOng/Projects/EditProject.vue @@ -181,6 +181,51 @@ + + + + +