*/ public Collection $employees; public string $search = ''; public array $status = []; public function mount(): void { $this->loadEmployees(); } protected function loadEmployees(): void { $this->employees = Employee::with(['user', 'user.referralCode', 'user.outlets']) ->when(! empty($this->search), function ($query) { return $query->where('full_name', 'like', '%'.$this->search.'%') ->orWhere('code', 'like', '%'.$this->search.'%') ->orWhereHas('user', fn ($q) => $q->where('email', 'like', '%'.$this->search.'%')) ->orWhereHas('user', fn ($q) => $q->where('username', 'like', '%'.$this->search.'%')); }) ->when(! empty($this->status), fn ($query) => $query->whereHas('user', fn ($q) => $q->whereIn('status', $this->status))) ->withoutDeveloper() ->latest() ->get(); } public function updatedSearch(string $value): void { $this->search = $value; $this->loadEmployees(); } public function updatedStatus(): void { $this->loadEmployees(); } public function delete(User $user): void { $user->delete(); $this->loadEmployees(); $this->toast('Pegawai berhasil dihapus.'); Flux::modals()->close(); } public function resetPassword(User $user): void { $user->update(['password' => Hash::make(config('myconfig.password_default'))]); $this->toast('Kata sandi pegawai berhasil direset.'); Flux::modals()->close(); } public function render(): View { return view('livewire.studio.master.user.index', [ 'pageTitle' => 'Pegawai', ]); } }