Delete.php
1 <?php 2 3 namespace App\Http\Livewire\Resolutions; 4 5 use App\Http\Services\ResolutionService; 6 use App\Models\Resolution; 7 use Illuminate\Foundation\Auth\Access\AuthorizesRequests; 8 use Livewire\Component; 9 use WireUi\Traits\Actions; 10 11 class Delete extends Component 12 { 13 use AuthorizesRequests, Actions; 14 15 public Resolution $resolution; 16 17 public int $entityId; 18 19 public function mount() 20 { 21 $this->resolution = Resolution::find($this->entityId); 22 $this->authorize('delete', $this->resolution); 23 } 24 25 public function remove() 26 { 27 try { 28 ResolutionService::delete($this->entityId); 29 $this->notification()->success( 30 __('resolutions.notifications.remove.success.title'), 31 __('resolutions.notifications.remove.success.message') 32 ); 33 $this->emit('closePanel'); 34 $this->emit('refresh'); 35 } catch (\Exception $e) { 36 $this->notification()->error( 37 'Error', 38 __('resolutions.notifications.remove.error.message') 39 ); 40 } 41 } 42 43 public function render() 44 { 45 return view('livewire.resolutions.delete'); 46 } 47 }