diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index c3640f3..b81271b 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -62,5 +62,6 @@ class Kernel extends HttpKernel 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'eligibility' => \App\Http\Middleware\ApplicationEligibility::class ]; } diff --git a/app/Http/Middleware/ApplicationEligibility.php b/app/Http/Middleware/ApplicationEligibility.php new file mode 100644 index 0000000..f091d8e --- /dev/null +++ b/app/Http/Middleware/ApplicationEligibility.php @@ -0,0 +1,59 @@ +id)->get(); + $eligible = true; + + $daysRemaining = 0; + + if (!$applications->isEmpty()) + { + foreach ($applications as $application) + { + $appTime = Carbon::parse($application->created_at); + if ($appTime->isSameMonth($curtime)) + { + + Log::warning('Notice: Application ID ' . $application->id . ' was found to be in the same month as today\'s time, making the user ' . Auth::user()->name . ' ineligible for application'); + $eligible = false; + } + } + + $allowedTime = Carbon::parse($applications->last()->created_at)->addMonth(); + $daysRemaining = $allowedTime->diffInDays(now()); + + } + + View::share('isEligibleForApplication', $eligible); + View::share('eligibilityDaysRemaining', $daysRemaining); + } + + + return $next($request); + } +} diff --git a/resources/views/dashboard/application-rendering/apply.blade.php b/resources/views/dashboard/application-rendering/apply.blade.php index cf15541..236b520 100644 --- a/resources/views/dashboard/application-rendering/apply.blade.php +++ b/resources/views/dashboard/application-rendering/apply.blade.php @@ -22,109 +22,119 @@ @endif + @if(!$isEligibleForApplication) + + + + @endif + @stop @section('content') -