You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
808 B
31 lines
808 B
<?php
|
|
namespace App\Components\Permission;
|
|
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
use Spatie\Permission\Models\Permission;
|
|
|
|
class Index extends Component
|
|
{
|
|
use WithPagination;
|
|
protected string $paginationTheme = 'bootstrap';
|
|
public $search = '';
|
|
protected $listeners = ['permissionSaved' => '$refresh'];
|
|
|
|
public function updatingSearch() { $this->resetPage(); }
|
|
|
|
public function delete($id)
|
|
{
|
|
Permission::findOrFail($id)->delete();
|
|
session()->flash('message', 'Permission deleted.');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
$permissions = Permission::where('name', 'like', "%{$this->search}%")
|
|
->orderByDesc('id')
|
|
->paginate(10);
|
|
|
|
return view('components.permission.index', compact('permissions'));
|
|
}
|
|
}
|
|
|