diff --git a/app/Filament/Resources/ChampionshipResource.php b/app/Filament/Resources/ChampionshipResource.php index ba990c0f..463d9695 100644 --- a/app/Filament/Resources/ChampionshipResource.php +++ b/app/Filament/Resources/ChampionshipResource.php @@ -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(), diff --git a/app/Http/Controllers/ChampionshipController.php b/app/Http/Controllers/ChampionshipController.php index c79da899..23674bc7 100644 --- a/app/Http/Controllers/ChampionshipController.php +++ b/app/Http/Controllers/ChampionshipController.php @@ -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'); diff --git a/app/Http/Controllers/Ngo/VolunteerController.php b/app/Http/Controllers/Ngo/VolunteerController.php index 428ab12b..f4cdb1d1 100644 --- a/app/Http/Controllers/Ngo/VolunteerController.php +++ b/app/Http/Controllers/Ngo/VolunteerController.php @@ -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', [