where('page_key',$pageKey)->where('is_enabled',true)->exists(); } catch (Throwable) { return false; } } public function renderRegion(string $pageKey, string $region): string { if (! $this->hasComposition($pageKey)) return ''; $placements = PageContent::query() ->with('document.type') ->where('page_key', $pageKey) ->where('region', $region) ->where('is_enabled', true) ->where(fn($q) => $q->whereNull('starts_at')->orWhere('starts_at','<=',now())) ->where(fn($q) => $q->whereNull('ends_at')->orWhere('ends_at','>',now())) ->orderBy('sort_order')->get(); return $placements->map(function (PageContent $placement): string { $document = $placement->document; if (! $document || ! $document->type || $document->status !== 'published') return ''; $view = 'stylist-theme-saasland::documents.'.$document->type->renderer; if (! View::exists($view)) $view = 'content::documents.unsupported'; return View::make($view, ['document'=>$document,'data'=>$document->data ?? [],'placement'=>$placement])->render(); })->implode("\n"); } }