Revert "merge 1"

This reverts commit 0bc6c20a6d.
This commit is contained in:
2022-10-24 01:03:43 +01:00
parent 0bc6c20a6d
commit 0c463d1f10
166 changed files with 1849 additions and 4266 deletions

View File

@@ -3,11 +3,7 @@
namespace App\Services;
use App\Exceptions\DiscordAccountRequiredException;
use App\Exceptions\IncompatibleAgeException;
use App\Exceptions\InvalidAgeException;
use App\Notifications\ApplicationConfirmed;
use Carbon\Carbon;
use ContextAwareValidator;
use App\Application;
use App\Events\ApplicationDeniedEvent;
@@ -26,27 +22,12 @@ use Illuminate\Support\Facades\Log;
class ApplicationService
{
/**
* @throws DiscordAccountRequiredException
* @throws IncompatibleAgeException
* @throws InvalidAgeException
*/
public function renderForm($vacancySlug)
{
$vacancyWithForm = Vacancy::with('forms')->where('vacancySlug', $vacancySlug)->get();
$firstVacancy = $vacancyWithForm->first();
if (is_null(Auth::user()->dob)) {
throw new InvalidAgeException("User must have added their age to apply for this vacancy.");
} elseif(Carbon::parse(Auth::user()->dob)->age < $firstVacancy->requiredAge) {
throw new IncompatibleAgeException("Sorry, you must be {$firstVacancy->requiredAge} or older to apply to {$firstVacancy->vacancyName}.");
}
if ($firstVacancy->requiresDiscord && !Auth::user()->hasDiscordConnection()) {
throw new DiscordAccountRequiredException('A discord account is required beyond this point.');
}
if (!$vacancyWithForm->isEmpty() && $firstVacancy->vacancyCount !== 0 && $firstVacancy->vacancyStatus == 'OPEN') {
return view('dashboard.application-rendering.apply')
->with([
@@ -55,7 +36,7 @@ class ApplicationService
]);
} else {
throw new ApplicationNotFoundException(__('The application you\'re looking for could not be found or it is currently unavailable.'), 404);
throw new ApplicationNotFoundException('The application you\'re looking for could not be found or it is currently unavailable.', 404);
}
}
@@ -113,12 +94,11 @@ class ApplicationService
'applicant' => $applicant->name
]);
User::whereHas('roles', function ($q) {
$q->where('name', 'admin');
})->get()->each(function ($user, $key) use ($application, $vacancy) {
$user->notify((new NewApplicant($application, $vacancy->first())));
});
foreach (User::all() as $user) {
if ($user->hasRole('admin')) {
$user->notify((new NewApplicant($application, $vacancy->first())));
}
}
$application->user->notify(new ApplicationConfirmed($application));
return true;