Created
May 7, 2020 14:39
-
-
Save jongravois/5c2d1af74ca3340e687c34afc1215295 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Livewire\Quality\Portal; | |
use App\Models\FormQualityObservation; | |
use App\Models\QualityCategory; | |
use App\Models\QualityProcess; | |
use Livewire\Component; | |
class FormWorksheet extends Component | |
{ | |
public $observationID; | |
public $observation; | |
public $processes; | |
public $processId; | |
public $owner; | |
public $catId; | |
public $cats; | |
public $displayReasons = []; | |
public $reasons = []; | |
public function mount($id) | |
{ | |
$this->observationID = $id; | |
$this->processes = QualityProcess::with('deficits', 'owner') | |
->orderBy('title') | |
->get(); | |
} // end function | |
public function render() | |
{ | |
if($this->processId) { | |
$proc = QualityProcess::with('deficits', 'owner')->find($this->processId); | |
$this->owner = $proc->owner->name; | |
$this->cats = $proc->deficits; | |
} // end if | |
$this->observation = FormQualityObservation::with('owner', 'quality') | |
->with('uploads') | |
->find($this->observationID); | |
return view('livewire.quality.portal.form-worksheet', [ | |
'cats' => QualityCategory::with('family')->get()->groupBy('family.title') | |
]); | |
} // end function | |
public function deselectCat($catID) | |
{ | |
$cat = QualityCategory::find($catID); | |
$index = array_search($catID, $this->reasons); | |
if($index !== false){ | |
unset($this->reasons[$index]); | |
} // end if | |
$idx = array_search($cat->cat,$this->displayReasons); | |
if($idx !== false){ | |
unset($this->displayReasons[$idx]); | |
} // end if | |
} // end function | |
public function selectCat($catID) | |
{ | |
$cat = QualityCategory::find($catID); | |
array_push($this->reasons, $catID); | |
array_push($this->displayReasons, $cat->cat); | |
} // end function | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment