@extends('layouts.main') @section('canonical') @endsection @section('content') @php // Data khud yahin se aata hai, controller se variables na bhi aayein to error nahi aayega if (!isset($all) || !($all instanceof \Illuminate\Support\Collection)) { $all = \App\Models\Blog::where('permission', 1)->orderBy('create_date', 'desc')->get(); } $banner = $all->take(3); // banner slider: latest 3 $featured = $all->first(); // left: sabse latest $side = $all->slice(1, 3)->values(); // right: 2nd, 3rd, 4th latest $categories = $all->pluck('category')->filter()->unique()->values(); // Images: public/assets/images/blogimages/ (DB me sirf file name, jaise valplast-hero.jpg) $img = function ($path) { if (!$path) { return asset('public/assets/images/blogimages/blog-placeholder.jpg'); } if (preg_match('#^(https?:)?//#', $path)) { return $path; // poora URL ho to waisa hi use hoga } return asset('public/assets/images/blogimages/'.ltrim($path, '/')); }; $link = function ($b) { return url('blogs/'.$b->id.'/'.$b->url); }; @endphp
{{-- ================= Banner slider (latest 3) ================= --}} @if($banner->count())
@foreach($banner as $i => $b)

{{ $b->title }}

{{ $b->short_desc }}

{{ $b->author ?: 'Admin' }} {{ $b->create_date->format('d/m/Y') }}
@endforeach
@if($banner->count() > 1)
@foreach($banner as $i => $b) @endforeach
@endif
@endif
{{-- ================= Latest + next 3 ================= --}} @if($featured)
{{ $featured->imagealttag ?: $featured->title }}

{{ $featured->title }}

{{ $featured->short_desc }}

@foreach($side as $s) {{ $s->imagealttag ?: $s->title }} {{ $s->title }} @endforeach
@endif {{-- ================= Categories ================= --}}
@foreach($categories as $cat) @endforeach
{{-- ================= Blog grid ================= --}}
@foreach($all as $idx => $b) {{ $b->imagealttag ?: $b->title }}

{{ $b->title }}

{{ $b->short_desc }}

@endforeach
Is category me abhi koi blog nahi hai.
{{-- ================= Pagination ================= --}}
@endsection