Skip to content

Commit

Permalink
fix empty states
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Jun 26, 2023
1 parent 843e592 commit 3ace199
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Filament/Resources/ChampionshipResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function form(Form $form): Form
->maxLength(255),
Forms\Components\Textarea::make('description')
->maxLength(65535)->columnSpanFull(),
Forms\Components\DatePicker::make('registration_start_date')->after(now())->required(),
Forms\Components\DatePicker::make('registration_start_date')->after(now()->toString())->required(),
Forms\Components\DatePicker::make('registration_end_date')->after('registration_start_date')->required(),
Forms\Components\DatePicker::make('start_date')->after('registration_end_date')->required(),
Forms\Components\DatePicker::make('end_date')->after('start_date')->required(),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ChampionshipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ChampionshipController extends Controller
{
public function index()
{
$championship = Championship::current()->first();
$championship = Championship::current()->firstOrFail();
$projects = $championship->activeStage()->projects()->paginate()->withQueryString()->through(fn ($project) =>$project->project);
$projectAmount = $championship->activeStage()->projects()->sum('amount_of_donation');
$projectDonationsNumber = $championship->activeStage()->projects()->sum('number_of_donation');
Expand Down
19 changes: 14 additions & 5 deletions app/Http/Controllers/Ngo/VolunteerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ class VolunteerController extends Controller
public function index(Request $request, $status = '')
{

$volunteers = Volunteer::whereHas('projects', function ($query) {
$query->whereIn('projects.id', auth()->user()->organization->projects->pluck('id'));
})->with('projects');
if (in_array($status, ['pending', 'approved', 'rejected'])) {
$volunteers->where('status', $status);
if (auth()->user()->organization == null) {
return redirect()->route('admin.ong.dashboard');
}
if (auth()->user()->organization->projects->count() == 0) {
$volunteers = Volunteer::where('id',0)->paginate();
}
else{
$volunteers = Volunteer::whereHas('projects', function ($query) {
$query->whereIn('projects.id', auth()->user()->organization->projects->pluck('id'));
})->with('projects');
if (in_array($status, ['pending', 'approved', 'rejected'])) {
$volunteers->where('status', $status);
}
}


return Inertia::render('AdminOng/Volunteers/Volunteers',
[
Expand Down

0 comments on commit 3ace199

Please sign in to comment.