Decrease vacancy slots by one when firing approval event
This commit is contained in:
parent
54b0d746fa
commit
e46ebfc63a
@ -108,8 +108,7 @@ class CountVotes extends Command
|
|||||||
if ($pollResult) {
|
if ($pollResult) {
|
||||||
$this->info('✓ Dispatched promotion event for applicant '.$application->user->name);
|
$this->info('✓ Dispatched promotion event for applicant '.$application->user->name);
|
||||||
if (! $this->option('dryrun')) {
|
if (! $this->option('dryrun')) {
|
||||||
$application->response->vacancy->vacancyCount -= 1;
|
$application->response->vacancy->decrease();
|
||||||
$application->response->vacancy->save();
|
|
||||||
|
|
||||||
event(new ApplicationApprovedEvent(Application::find($application->id)));
|
event(new ApplicationApprovedEvent(Application::find($application->id)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,6 +47,7 @@ class PromoteUser
|
|||||||
public function handle(ApplicationApprovedEvent $event)
|
public function handle(ApplicationApprovedEvent $event)
|
||||||
{
|
{
|
||||||
$event->application->setStatus('APPROVED');
|
$event->application->setStatus('APPROVED');
|
||||||
|
$event->application->response->vacancy->decrease();
|
||||||
|
|
||||||
$staffProfile = StaffProfile::create([
|
$staffProfile = StaffProfile::create([
|
||||||
'userID' => $event->application->user->id,
|
'userID' => $event->application->user->id,
|
||||||
|
@ -89,6 +89,21 @@ class Vacancy extends Model
|
|||||||
Log::warning('Vacancies: Vacancy '.$this->id.' ('.$this->vacancyName.') closed by '.Auth::user()->name);
|
Log::warning('Vacancies: Vacancy '.$this->id.' ('.$this->vacancyName.') closed by '.Auth::user()->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function decrease()
|
||||||
|
{
|
||||||
|
if ($this->vacancyCount !== 0)
|
||||||
|
{
|
||||||
|
$this->update([
|
||||||
|
'vacancyCount' => $this->vacancyCount - 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
Log::info('Vacancies: Decreased vacancy slots by one.', [
|
||||||
|
'vacancyId' => $this->id,
|
||||||
|
'vacancyName' => $this->vacancyName
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the Modal is attached to the $checkingTeam Model.
|
* Check if the Modal is attached to the $checkingTeam Model.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user