@php use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use Illuminate\Support\Facades\Route; // context $route = Route::currentRouteName(); $path = '/'.ltrim(request()->path(), '/'); // config global (fallback-uri) $cfg = DB::table('website_configs')->first(); $extra = $cfg?->extra ? json_decode($cfg->extra, true) : []; $suffix = data_get($extra, 'seo.default_title_suffix', ''); $defDesc = data_get($extra, 'seo.default_description', ''); $defKeywords = data_get($extra, 'seo.default_keywords', ''); $defRobots = data_get($extra, 'seo.default_robots', 'index,follow'); // seo_pages (preferă path exact, altfel route) $seoRow = DB::table('seo_pages') ->where(function($q) use ($route,$path){ $q->where('path', $path)->orWhere('route', $route); }) ->orderByRaw("CASE WHEN path = ? THEN 0 ELSE 1 END", [$path]) ->first(); // ce vine din view-ul paginii (opțional) $vTitle = trim($__env->yieldContent('title')); $vDesc = trim($__env->yieldContent('meta_description')); $vKeywords = trim($__env->yieldContent('meta_keywords')); $vRobots = trim($__env->yieldContent('meta_robots')); $vCanonical = trim($__env->yieldContent('meta_canonical')); // resolve finale $pageTitle = $seoRow->title ?? ($vTitle !== '' ? $vTitle : 'Savero — Ecommerce'); if ($suffix && !Str::contains($pageTitle, $suffix)) $pageTitle .= $suffix; $pageDesc = $seoRow->description ?? ($vDesc !== '' ? $vDesc : $defDesc); $pageKW = $seoRow->keywords ?? ($vKeywords !== '' ? $vKeywords : $defKeywords); $pageRob = $seoRow->robots ?? ($vRobots !== '' ? $vRobots : 'index,follow'); $pageCanon = $seoRow->canonical_url ?? ($vCanonical !== '' ? $vCanonical : url()->current()); @endphp