diff --git a/app/Filament/Resources/ProjectResource.php b/app/Filament/Resources/ProjectResource.php index 3682481f..73337c73 100644 --- a/app/Filament/Resources/ProjectResource.php +++ b/app/Filament/Resources/ProjectResource.php @@ -32,6 +32,12 @@ class ProjectResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-collection'; + protected static function getNavigationBadge(): ?string + { + + return (string) static::$model::whereIsPublished()->count(); + } + public static function form(Form $form): Form { return $form @@ -108,7 +114,7 @@ public static function table(Table $table): Table ]), Tables\Columns\TextColumn::make('name'), Tables\Columns\TextColumn::make('category'), - Tables\Columns\TextColumn::make('target_budget'), + Tables\Columns\TextColumn::make('created_at')->date(), ]); } @@ -162,11 +168,27 @@ public static function getPages(): array public static function getWidgetColumns(): array { return [ + Tables\Columns\TextColumn::make('id')->formatStateUsing(function (Project $record) { + return sprintf('#%d',$record->id); + }) + ->label(__('project.labels.id')), ResourceNameColumn::make('project_info') ->label(__('project.labels.project')), - Tables\Columns\TextColumn::make('category') + Tables\Columns\TextColumn::make('category')->formatStateUsing(fn (Project $record)=> $record->categories->pluck('name')->join(', ')) ->label(__('project.labels.category')), - Tables\Columns\TextColumn::make('target_budget') + Tables\Columns\TextColumn::make('counties')->formatStateUsing(function (Project $record){ +// dd($record->is_national); + if ($record->is_national) + { + return __('project.labels.national'); + } + return $record->counties->pluck('name')->join(', '); + + }) + ->label(__('project.labels.counties')), + Tables\Columns\TextColumn::make('target_budget')->formatStateUsing(function (Project $record) { + return number_format($record->target_budget, 2, ',', '.'); + }) ->label(__('project.labels.target_budget')), Tables\Columns\TextColumn::make('created_at')->date('d-m-Y') ->label(__('project.labels.created_at')), diff --git a/app/Filament/Resources/ProjectResource/Widgets/ApprovedProject.php b/app/Filament/Resources/ProjectResource/Widgets/ApprovedProject.php index a5401a21..a691644a 100644 --- a/app/Filament/Resources/ProjectResource/Widgets/ApprovedProject.php +++ b/app/Filament/Resources/ProjectResource/Widgets/ApprovedProject.php @@ -15,7 +15,7 @@ class ApprovedProject extends BaseProjectWidget protected function getTableHeading(): string { - return __('project.heading.approved'); + return __('project.heading.approved',['number' => $this->getTableQuery()->count()]); } protected function getTableQuery(): Builder diff --git a/app/Filament/Resources/ProjectResource/Widgets/NewProject.php b/app/Filament/Resources/ProjectResource/Widgets/NewProject.php index 0447246c..1fe28af6 100644 --- a/app/Filament/Resources/ProjectResource/Widgets/NewProject.php +++ b/app/Filament/Resources/ProjectResource/Widgets/NewProject.php @@ -21,7 +21,7 @@ class NewProject extends BaseProjectWidget protected function getTableHeading(): string { - return __('project.heading.pending'); + return __('project.heading.pending',['number' => $this->getTableQuery()->count()]); } protected function getTableQuery(): Builder @@ -40,7 +40,7 @@ protected function getTableActions(): array ViewAction::make() ->label(__('project.actions.view')) - ->url(fn (Project $record) => route('filament.resources.projects.edit', $record)) + ->url(fn (Project $record) => route('filament.resources.projects.view', $record)) ->icon(null) ->size('sm'), Action::make('edit') diff --git a/app/Filament/Resources/ProjectResource/Widgets/RejectedProject.php b/app/Filament/Resources/ProjectResource/Widgets/RejectedProject.php index b108e2cd..a3ed7f33 100644 --- a/app/Filament/Resources/ProjectResource/Widgets/RejectedProject.php +++ b/app/Filament/Resources/ProjectResource/Widgets/RejectedProject.php @@ -15,7 +15,7 @@ class RejectedProject extends BaseProjectWidget protected function getTableHeading(): string { - return __('project.heading.rejected'); + return __('project.heading.rejected', ['number' => $this->getTableQuery()->count()]); } protected function getTableQuery(): Builder diff --git a/app/Models/Project.php b/app/Models/Project.php index c2968297..2beb4643 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -55,6 +55,7 @@ class Project extends Model implements HasMedia 'videos' => 'array', 'external_links' => 'array', 'start' => 'date:Y-m-d', + 'is_national' => 'boolean', 'end' => 'date:Y-m-d', 'accepting_volunteers' => 'boolean', 'accepting_comments' => 'boolean', diff --git a/app/Policies/ProjectPolicy.php b/app/Policies/ProjectPolicy.php index 02de06c7..192a0255 100644 --- a/app/Policies/ProjectPolicy.php +++ b/app/Policies/ProjectPolicy.php @@ -16,6 +16,10 @@ public function viewAny(User $user): bool public function view(User $user, Project $project): bool { + if ($user->isSuperAdmin()) + { + return true; + } return $user->belongsToOrganization($project->organization); } diff --git a/app/Services/ProjectService.php b/app/Services/ProjectService.php index dca3a7a9..26db2720 100644 --- a/app/Services/ProjectService.php +++ b/app/Services/ProjectService.php @@ -94,7 +94,6 @@ public function changeStatus($id, string $status): void } $this->project->status = ProjectStatus::pending->value; $this->project->save(); -// dd($this->project); if ($status === ProjectStatus::approved->value) { $this->sendCreateNotifications($this->project); } diff --git a/lang/ro/project.php b/lang/ro/project.php index 74437249..95379a98 100644 --- a/lang/ro/project.php +++ b/lang/ro/project.php @@ -18,6 +18,7 @@ 'disabled' => 'Inactivă', ], 'actions' => [ + 'view' => 'Vezi', 'edit' => 'Editează', 'approve' => 'Aprobă', 'reject' => 'Respinge', @@ -33,10 +34,10 @@ 'other' => 'Altele', ], 'heading' => [ - 'pending' => 'Proiecte in curs de aprobare', - 'change_request' => 'Proiecte cu modificări', - 'approved' => 'Proiecte aprobate', - 'rejected' => 'Proiecte refuzate', + 'pending' => 'Proiecte in curs de aprobare (:number)', + 'change_request' => 'Proiecte cu modificări (:number)', + 'approved' => 'Proiecte aprobate (:number)', + 'rejected' => 'Proiecte refuzate (:number)', ], 'label' => [ 'singular' => 'Proiect', @@ -44,8 +45,10 @@ ], 'labels' => [ + 'id' => 'ID', 'project' => 'Proiect', 'category' => 'Categorie', + 'national' => 'Național', 'target_budget' => 'Target', 'created_at' => 'Data creării', 'organization' => 'Organizație',