diff --git a/app/Http/Controllers/Dashboard/ProjectController.php b/app/Http/Controllers/Dashboard/ProjectController.php index 5f4df4cb..b5b66113 100644 --- a/app/Http/Controllers/Dashboard/ProjectController.php +++ b/app/Http/Controllers/Dashboard/ProjectController.php @@ -20,17 +20,14 @@ class ProjectController extends Controller { public function index(Request $request) { - // TODO: fix issue with approved projects not being displayed $projectStatus = $request->get('project_status'); - - return Inertia::render('AdminOng/Projects/Projects', [ 'query' => ProjectCardResource::collection( Project::query() - ->where('organization_id', auth()->user()->organization_id) ->when($projectStatus, function (Builder $query) use ($projectStatus) { return $query->statusIs($projectStatus); }) + ->where('organization_id', auth()->user()->organization_id) ->paginate(16) ->withQueryString() ), diff --git a/app/Http/Requests/RegistrationRequest.php b/app/Http/Requests/RegistrationRequest.php index b33226f0..3a2277d2 100644 --- a/app/Http/Requests/RegistrationRequest.php +++ b/app/Http/Requests/RegistrationRequest.php @@ -28,7 +28,7 @@ public function rules(): array $rules = array_merge($rules, [ 'ngo' => ['array', 'required'], 'ngo.name' => ['string', 'required'], - 'ngo.description' => ['string', 'required'], + 'ngo.description' => ['string', 'required', 'max:1000'], 'ngo.logo' => ['required', 'image'], 'ngo.statute' => ['required', 'file'], 'ngo.street_address' => ['string', 'required'], @@ -39,8 +39,8 @@ public function rules(): array 'ngo.domains' => ['array', 'required'], 'ngo.counties' => ['array', 'required'], 'ngo.volunteer' => ['boolean'], - 'ngo.why_volunteer' => ['string', 'nullable'], - 'ngo.website' => ['string', 'nullable'], + 'ngo.why_volunteer' => ['string', 'nullable', 'max:1000'], + 'ngo.website' => ['string', 'nullable', 'url'], ]); } diff --git a/app/Traits/HasProjectStatus.php b/app/Traits/HasProjectStatus.php index 420242ce..81629a78 100644 --- a/app/Traits/HasProjectStatus.php +++ b/app/Traits/HasProjectStatus.php @@ -57,9 +57,9 @@ public function scopeWhereIsOpen(Builder $query): Builder ->whereDate('end', '>=', now()); } - public function scopeWhereStartsSoon(): Builder + public function scopeWhereStartsSoon(Builder $query): Builder { - return $this->whereIsPublished() + return $query->whereIsPublished() ->whereDate('start', '>=', now()) ->orderBy('start'); } @@ -72,14 +72,14 @@ public function scopeWhereIsDraft(Builder $query): Builder public function scopeStatusIs(Builder $query, $status): Builder { return match ($status) { - 'draft' => $this->whereIsDraft(), - 'pending' => $this->whereIsPending(), - 'approved' => $this->whereIsApproved(), - 'rejected' => $this->whereIsRejected(), - 'published' => $this->whereIsPublished(), - 'open' => $this->whereIsOpen(), - 'starts_soon' => $this->whereStartsSoon(), - default => $this->newQuery(), + 'draft' => $query->whereIsDraft(), + 'pending' => $query->whereIsPending(), + 'approved' => $query->whereIsApproved(), + 'rejected' => $query->whereIsRejected(), + 'published' => $query->whereIsPublished(), + 'open' => $query->whereIsOpen(), + 'starts_soon' => $query->whereStartsSoon(), + default => $query, }; } }