|
@@ 580-655 (lines=76) @@
|
| 577 |
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
| 578 |
|
* @return \Illuminate\Http\Response |
| 579 |
|
*/ |
| 580 |
|
public function updateEssentialSkills(Request $request, JobPoster $jobPoster) |
| 581 |
|
{ |
| 582 |
|
$applicant = Auth::user()->applicant; |
| 583 |
|
$application = $this->getApplicationFromJob($jobPoster); |
| 584 |
|
|
| 585 |
|
// Ensure user has permissions to update this application. |
| 586 |
|
$this->authorize('update', $application); |
| 587 |
|
|
| 588 |
|
$skillDeclarations = $request->input('skill_declarations'); |
| 589 |
|
$claimedStatusId = SkillStatus::where('name', 'claimed')->firstOrFail()->id; |
| 590 |
|
|
| 591 |
|
// Save new skill declarartions. |
| 592 |
|
if (isset($skillDeclarations['new'])) { |
| 593 |
|
foreach ($skillDeclarations['new'] as $skillType => $typeInput) { |
| 594 |
|
foreach ($typeInput as $criterion_id => $skillDeclarationInput) { |
| 595 |
|
$skillDeclaration = new SkillDeclaration(); |
| 596 |
|
$skillDeclaration->applicant_id = $applicant->id; |
| 597 |
|
$skillDeclaration->skill_id = Criteria::find($criterion_id)->skill->id; |
| 598 |
|
$skillDeclaration->skill_status_id = $claimedStatusId; |
| 599 |
|
$skillDeclaration->fill([ |
| 600 |
|
'description' => $skillDeclarationInput['description'], |
| 601 |
|
'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null, |
| 602 |
|
]); |
| 603 |
|
$skillDeclaration->save(); |
| 604 |
|
|
| 605 |
|
$referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references'); |
| 606 |
|
$skillDeclaration->references()->sync($referenceIds); |
| 607 |
|
|
| 608 |
|
$sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples'); |
| 609 |
|
$skillDeclaration->work_samples()->sync($sampleIds); |
| 610 |
|
} |
| 611 |
|
} |
| 612 |
|
} |
| 613 |
|
|
| 614 |
|
// Update old declarations. |
| 615 |
|
if (isset($skillDeclarations['old'])) { |
| 616 |
|
foreach ($skillDeclarations['old'] as $skillType => $typeInput) { |
| 617 |
|
foreach ($typeInput as $id => $skillDeclarationInput) { |
| 618 |
|
// Ensure this declaration belongs to this applicant. |
| 619 |
|
$skillDeclaration = $applicant->skill_declarations->firstWhere('id', $id); |
| 620 |
|
if ($skillDeclaration != null) { |
| 621 |
|
// skill_id and skill_status cannot be changed. |
| 622 |
|
$skillDeclaration->fill([ |
| 623 |
|
'description' => $skillDeclarationInput['description'], |
| 624 |
|
'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null, |
| 625 |
|
]); |
| 626 |
|
$skillDeclaration->save(); |
| 627 |
|
|
| 628 |
|
$referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references'); |
| 629 |
|
$skillDeclaration->references()->sync($referenceIds); |
| 630 |
|
|
| 631 |
|
$sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples'); |
| 632 |
|
$skillDeclaration->work_samples()->sync($sampleIds); |
| 633 |
|
} else { |
| 634 |
|
Log::warning("Applicant $applicant->id attempted to update skill declaration with invalid id: $id"); |
| 635 |
|
} |
| 636 |
|
} |
| 637 |
|
} |
| 638 |
|
} |
| 639 |
|
|
| 640 |
|
// Redirect to correct page. |
| 641 |
|
switch ($request->input('submit')) { |
| 642 |
|
case 'save_and_quit': |
| 643 |
|
return redirect()->route('applications.index'); |
| 644 |
|
break; |
| 645 |
|
case 'save_and_continue': |
| 646 |
|
case 'next': |
| 647 |
|
return redirect()->route('job.application.edit.4', $jobPoster); |
| 648 |
|
break; |
| 649 |
|
case 'previous': |
| 650 |
|
return redirect()->route('job.application.edit.2', $jobPoster); |
| 651 |
|
break; |
| 652 |
|
default: |
| 653 |
|
return redirect()->back()->withInput(); |
| 654 |
|
} |
| 655 |
|
} |
| 656 |
|
|
| 657 |
|
/** |
| 658 |
|
* Update the Application Asset Skills in storage for the specified job. |
|
@@ 664-739 (lines=76) @@
|
| 661 |
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
| 662 |
|
* @return \Illuminate\Http\Response |
| 663 |
|
*/ |
| 664 |
|
public function updateAssetSkills(Request $request, JobPoster $jobPoster) |
| 665 |
|
{ |
| 666 |
|
$applicant = Auth::user()->applicant; |
| 667 |
|
$application = $this->getApplicationFromJob($jobPoster); |
| 668 |
|
|
| 669 |
|
// Ensure user has permissions to update this application. |
| 670 |
|
$this->authorize('update', $application); |
| 671 |
|
|
| 672 |
|
$skillDeclarations = $request->input('skill_declarations'); |
| 673 |
|
$claimedStatusId = SkillStatus::where('name', 'claimed')->firstOrFail()->id; |
| 674 |
|
|
| 675 |
|
// Save new skill declarartions. |
| 676 |
|
if (isset($skillDeclarations['new'])) { |
| 677 |
|
foreach ($skillDeclarations['new'] as $skillType => $typeInput) { |
| 678 |
|
foreach ($typeInput as $criterion_id => $skillDeclarationInput) { |
| 679 |
|
$skillDeclaration = new SkillDeclaration(); |
| 680 |
|
$skillDeclaration->applicant_id = $applicant->id; |
| 681 |
|
$skillDeclaration->skill_id = Criteria::find($criterion_id)->skill->id; |
| 682 |
|
$skillDeclaration->skill_status_id = $claimedStatusId; |
| 683 |
|
$skillDeclaration->fill([ |
| 684 |
|
'description' => $skillDeclarationInput['description'], |
| 685 |
|
'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null, |
| 686 |
|
]); |
| 687 |
|
$skillDeclaration->save(); |
| 688 |
|
|
| 689 |
|
$referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references'); |
| 690 |
|
$skillDeclaration->references()->sync($referenceIds); |
| 691 |
|
|
| 692 |
|
$sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples'); |
| 693 |
|
$skillDeclaration->work_samples()->sync($sampleIds); |
| 694 |
|
} |
| 695 |
|
} |
| 696 |
|
} |
| 697 |
|
|
| 698 |
|
// Update old declarations. |
| 699 |
|
if (isset($skillDeclarations['old'])) { |
| 700 |
|
foreach ($skillDeclarations['old'] as $skillType => $typeInput) { |
| 701 |
|
foreach ($typeInput as $id => $skillDeclarationInput) { |
| 702 |
|
// Ensure this declaration belongs to this applicant. |
| 703 |
|
$skillDeclaration = $applicant->skill_declarations->firstWhere('id', $id); |
| 704 |
|
if ($skillDeclaration != null) { |
| 705 |
|
// skill_id and skill_status cannot be changed. |
| 706 |
|
$skillDeclaration->fill([ |
| 707 |
|
'description' => $skillDeclarationInput['description'], |
| 708 |
|
'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null, |
| 709 |
|
]); |
| 710 |
|
$skillDeclaration->save(); |
| 711 |
|
|
| 712 |
|
$referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references'); |
| 713 |
|
$skillDeclaration->references()->sync($referenceIds); |
| 714 |
|
|
| 715 |
|
$sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples'); |
| 716 |
|
$skillDeclaration->work_samples()->sync($sampleIds); |
| 717 |
|
} else { |
| 718 |
|
Log::warning("Applicant $applicant->id attempted to update skill declaration with invalid id: $id"); |
| 719 |
|
} |
| 720 |
|
} |
| 721 |
|
} |
| 722 |
|
} |
| 723 |
|
|
| 724 |
|
// Redirect to correct page. |
| 725 |
|
switch ($request->input('submit')) { |
| 726 |
|
case 'save_and_quit': |
| 727 |
|
return redirect()->route('applications.index'); |
| 728 |
|
break; |
| 729 |
|
case 'save_and_continue': |
| 730 |
|
case 'next': |
| 731 |
|
return redirect()->route('job.application.edit.5', $jobPoster); |
| 732 |
|
break; |
| 733 |
|
case 'previous': |
| 734 |
|
return redirect()->route('job.application.edit.3', $jobPoster); |
| 735 |
|
break; |
| 736 |
|
default: |
| 737 |
|
return redirect()->back()->withInput(); |
| 738 |
|
} |
| 739 |
|
} |
| 740 |
|
|
| 741 |
|
/** |
| 742 |
|
* Submit the Application for the specified job. |