get('notification'); if ($hasNotification) { $this->js(<<<'JS' const url = new URL(window.location); url.search = ''; window.history.replaceState({}, '', url); JS); $this->toast($hasNotification); } $this->loadOutlets(); } protected function loadOutlets(): void { $this->outlets = Outlet::with(['openingHours', 'facilities']) ->when(! empty($this->search), fn ($query) => $query->where('name', 'like', '%'.$this->search.'%')) ->when(! empty($this->status), fn ($query) => $query->whereIn('status', $this->status)) ->latest() ->get(); } protected function formatOpeningHours(Outlet $outlet): array { if (! $outlet->openingHours || $outlet->openingHours->isEmpty()) { return []; } return $outlet->openingHours->mapWithKeys(fn ($hour) => [ Str::ucfirst(Str::lower(Day::from($hour->day->value)->label())) => [ 'open' => formatTime($hour->open_time), 'close' => formatTime($hour->close_time), 'is_closed' => $hour->open_time === null && $hour->close_time === null, ], ])->toArray(); } protected function getFeaturedImage(Outlet $outlet): string { $mediaCollection = $this->mapMediaCollection($outlet->getMedia('featured_image')); return data_get($mediaCollection[0] ?? null, 'temporaryUrl', asset('assets/images/logo.png')); } protected function getGalleryImages(Outlet $outlet): array { return collect($this->mapMediaCollection($outlet->getMedia('images'))) ->pluck('temporaryUrl') ->filter() ->values() ->toArray(); } public function updatedSearch(string $value): void { $this->search = $value; $this->loadOutlets(); } public function updatedStatus(): void { $this->loadOutlets(); } public function delete(Outlet $outlet): void { $this->canOrAbort('delete outlet'); $outlet->delete(); $this->toast('Outlet berhasil dihapus.'); $this->loadOutlets(); Flux::modals()->close(); } public function render(): View { return view('livewire.studio.master.outlet.index', [ 'pageTitle' => 'Outlet', ]); } }