Created
May 12, 2021 21:32
-
-
Save jongravois/8ebd7662447adcb2f1718ff4e6454684 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\Workscopes; | |
use App\Models\Disassembly; | |
use Livewire\Component; | |
class WorkscopesHome extends Component | |
{ | |
public $search = ''; | |
public $workscopes = []; | |
public $sortField = 'registration'; | |
public $sortAsc = true; | |
protected $listeners = [ | |
'manifestUploaded' | |
]; | |
public function render() | |
{ | |
$this->workscopes = Disassembly::fullSearch($this->search) | |
->with('location') | |
->dashboard() | |
->latest() | |
->get(); | |
return view('livewire.workscopes.workscopes-home'); | |
} // end function | |
public function create(): void | |
{ | |
$this->redirect('/workscopes/generator'); | |
} // end function | |
public function deleteWorkscope($id): void | |
{ | |
Disassembly::find($id)->delete(); | |
$this->dispatchBrowserEvent('toast', [ | |
'type' => 'success', | |
'msg' => 'The WorkScope has been deleted.' | |
]); | |
$this->dispatchBrowserEvent('deleted'); | |
} // end function | |
public function toggleDash($id): void | |
{ | |
$dis = Disassembly::whereId($id)->first(); | |
$dis->update([ | |
'on_dash' => ! $dis->on_dash | |
]); | |
} // end function | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment