Skip to content

Instantly share code, notes, and snippets.

@jongravois
Created May 12, 2021 21:32
Show Gist options
  • Save jongravois/8ebd7662447adcb2f1718ff4e6454684 to your computer and use it in GitHub Desktop.
Save jongravois/8ebd7662447adcb2f1718ff4e6454684 to your computer and use it in GitHub Desktop.
<?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