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