Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Oct 9, 2023
1 parent 0125aaf commit a332997
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/Dashboard/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public function index(Request $request)
{
// TODO: fix issue with approved projects not being displayed
$projectStatus = $request->get('project_status');
// dd($projectStatus);

return Inertia::render('AdminOng/Projects/Projects', [
'query' => ProjectCardResource::collection(
Project::query()
->where('organization_id', auth()->user()->organization_id)
->when($projectStatus, function (Builder $query, $projectStatus) {
return $query->status($projectStatus);
->when($projectStatus, function (Builder $query) use ($projectStatus) {
return $query->statusIs($projectStatus);
})
->paginate(16)
->withQueryString()
Expand Down
13 changes: 13 additions & 0 deletions app/Traits/HasProjectStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,17 @@ public function scopeWhereStartsSoon(): Builder
->whereDate('start', '>=', now())
->orderBy('start');
}
public function scopeStatusIs($status): Builder
{
// dd($status);
return match ($status){
'pending' => $this->whereIsPending(),
'approved' => $this->whereIsApproved(),
'rejected' => $this->whereIsRejected(),
'published' => $this->whereIsPublished(),
'open' => $this->whereIsOpen(),
'starts_soon' => $this->whereStartsSoon(),
default => $this->newQuery(),
};
}
}
9 changes: 2 additions & 7 deletions resources/js/Layouts/DashboardLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
icon: OfficeBuildingIcon,
},
{
name: 'Proiectele mele',
name: 'Proiecte',
route: route('dashboard.projects.index'),
icon: FolderIcon,
subMenu: [
Expand All @@ -118,15 +118,10 @@
route: route('dashboard.projects.index', { project_status: 'draft' }),
icon: FolderRemoveIcon,
},
{
name: 'regional_projects',
route: route('dashboard.projects.regional.create'),
icon: FolderRemoveIcon,
},
],
},
{
name: 'Proiectele mele regionale',
name: 'Proiectele regionale',
route: route('dashboard.projects.regional.index'),
icon: FolderIcon,
subMenu: [
Expand Down

0 comments on commit a332997

Please sign in to comment.