modalTitle = 'Crear usuario nuevo'; $this->btnSubmitTxt = 'Crear usuario'; $this->statuses = [ User::STATUS_ENABLED => ['title' => 'Activo', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_ENABLED]], User::STATUS_DISABLED => ['title' => 'Deshabilitado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_DISABLED]], User::STATUS_REMOVED => ['title' => 'Eliminado', 'class' => 'badge bg-label-' . User::$statusListClass[User::STATUS_REMOVED]], ]; $roles = Role::whereNotIn('name', ['Patient', 'Doctor'])->get(); $this->roles_html_select = ""; $this->status_options = [ User::STATUS_ENABLED => User::$statusList[User::STATUS_ENABLED], User::STATUS_DISABLED => User::$statusList[User::STATUS_DISABLED], ]; } public function countUsers() { $this->total = User::count(); $this->enabled = User::where('status', User::STATUS_ENABLED)->count(); $this->disabled = User::where('status', User::STATUS_DISABLED)->count(); } public function edit($id) { $user = User::findOrFail($id); $this->indexAlert = ''; $this->modalTitle = 'Editar usuario: ' . $id; $this->btnSubmitTxt = 'Guardar cambios'; $this->userId = $user->id; $this->name = $user->name; $this->email = $user->email; $this->password = ''; $this->roles = $user->roles->pluck('name')->toArray(); $this->src_photo = $user->profile_photo_url; $this->status = $user->status; $this->dispatch('openModal'); } public function delete($id) { $user = User::find($id); if ($user) { // Eliminar la imagen de perfil si existe if ($user->profile_photo_path) Storage::disk('public')->delete($user->profile_photo_path); // Eliminar el usuario $user->delete(); $this->indexAlert = ''; $this->dispatch('refreshUserCount'); $this->dispatch('afterDelete'); } else { $this->indexAlert = ''; } } public function render() { return view('vuexy-admin::livewire.users.index', [ 'users' => User::paginate(10), ]); } }