roleService = $roleService; $this->appRoleService = $appRoleService; } public function mount(): void { $this->headers = TableHeader::collect([ new TableHeader(key: 'name', label: 'Name'), new TableHeader(key: 'apps', label: 'Apps'), new TableHeader(key: '', label: 'Users'), ], DataCollection::class); } #[Computed] public function getRoles(): PaginatedDataCollection { return $this->roleService->getAll(); } public function searchApps(string $value = ''): void { $this->appsSearchable = $this ->appRoleService ->searchAppsForSelect($value) ->toArray(); } public function selectAllApps(): void { $this->form->appIds = $this->appRoleService->getAllAppIds(); $this->appsSearchable = $this->appRoleService->searchAppsForSelect('')->toArray(); } public function clearApps(): void { $this->form->appIds = []; } public function openCreateModal(): void { $this->form->reset(); $this->searchApps(); $this->showCreateModal = true; } public function save(): void { $this->form->validate(); $this->attempt( action: function (): void { $role = $this->roleService->create(new CreateRoleData(name: $this->form->name)); $this->appRoleService->assign( new AssignAppsToRoleData( roleId: $role->id, duration: $this->form->duration, appIds: $this->form->appIds ) ); $this->showCreateModal = false; $this->form->reset(); unset($this->getRoles); }, successMessage: 'Role created successfully!', ); } public function delete(int $roleId): void { $this->attempt( action: function () use ($roleId): void { $this->roleService->delete($roleId); unset($this->getRoles); }, successMessage: 'Role deleted successfully!', ); } }; ?>
Add new role @scope('cell_name', $row) {{ $row->name }} @endscope @scope('cell_apps', $row) @foreach($row->apps as $app) @php /** @var RoleAppData $app */ @endphp @endforeach @endscope @scope('actions', $row)
@endscope
Cancel Save Role