Remove.php
1 <?php 2 3 namespace App\Http\Livewire\Keys; 4 5 use App\Http\Services\KeyService; 6 use Exception; 7 use Illuminate\Foundation\Auth\Access\AuthorizesRequests; 8 use Livewire\Component; 9 use WireUi\Traits\Actions; 10 11 class Remove extends Component 12 { 13 use AuthorizesRequests, Actions; 14 15 public int $entityId = 0; 16 17 public function remove() 18 { 19 //$this->authorize('can_remove_keys'); 20 21 try { 22 KeyService::remove($this->entityId); 23 24 // UI Trick for delaying spinner 25 if (config('app.env') !== 'testing') { 26 sleep(1); 27 } 28 29 $this->emitUp('closePanel'); 30 $this->emitTo('keys.index', 'refresh'); 31 32 $this->notification()->success( 33 __('keys.notifications.remove.success.title'), 34 __('keys.notifications.remove.success.message') 35 ); 36 } catch (Exception $e) { 37 $this->notification()->error( 38 'Error', 39 $e->getMessage() 40 ); 41 } 42 } 43 44 public function render() 45 { 46 return view('livewire.keys.remove'); 47 } 48 }