@php use App\Helpers\SchemaCollector; $blogList = method_exists($blogs, 'items') ? $blogs->items() : $blogs; $logoUrl = Settings('logo'); if ($logoUrl && !str_starts_with($logoUrl, 'http')) { $logoUrl = url($logoUrl); } $blogItems = collect($blogList ?? [])->map(function($blog) use ($logoUrl) { $imageUrl = getBlogImage($blog->thumbnail); if ($imageUrl && !str_starts_with($imageUrl, 'http')) { $imageUrl = url($imageUrl); } $authorImageUrl = $blog->user->image ?? null; if ($authorImageUrl && !str_starts_with($authorImageUrl, 'http')) { $authorImageUrl = url($authorImageUrl); } $datePublished = $blog->published_at ? \Carbon\Carbon::parse($blog->published_at)->toIso8601String() : null; $dateModified = $blog->updated_at ? \Carbon\Carbon::parse($blog->updated_at)->toIso8601String() : null; return [ '@type' => 'BlogPosting', 'headline' => $blog->title, 'description' => $blog->excerpt ?? \Illuminate\Support\Str::limit(strip_tags($blog->body), 160), 'image' => $imageUrl, 'author' => [ '@type' => 'Person', 'name' => $blog->user->name ?? 'Admin', 'url' => $blog->user ? route('instructorDetails', [$blog->user->id, \Illuminate\Support\Str::slug($blog->user->name ?? 'admin')]) : url('/'), 'image' => $authorImageUrl, ], 'datePublished' => $datePublished, 'dateModified' => $dateModified, 'mainEntityOfPage' => route('blogDetails', $blog->slug), 'publisher' => [ '@type' => 'Organization', 'name' => Settings('site_title') ?? 'InfixLMS', 'logo' => ['@type' => 'ImageObject', 'url' => $logoUrl], ], ]; })->toArray(); if (!empty($blogItems)) { SchemaCollector::addBlogs($blogItems); } @endphp