@extends('layouts.app')
@section('metades')
    <meta name="description" content="{{ $data['metaDescription'] }}" />
    <meta name="author" content="Kultikri Teacher Training Institute of Higher Studies (KTTIHS)" />
    <meta name="keywords" content="Kultikri Teacher Training Institute of Higher Studies (KTTIHS)" />
@endsection
@section('title')
    <title>{{ $data['metaTitle'] }}</title>
@endsection
@section('content')
    @foreach ($data['moduleItems'] as $item)
        @if ($item['slug'] == 'notice-3')
            <section class="features-box py-5">
                <div class="features-box1 py-5">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-12 mb-sm-0 mb-3 ">
    <div class="w-100 title-bx1">
        <h3 class="one8">{{ $item['title'] }} </h3>
    </div>
    @if (count($item['dynamicSections']) > 0)
        {{-- Sort dynamicSections in descending order by 'createdAt' --}}
        @php
            $sortedSections = collect($item['dynamicSections'])->sortByDesc('createdAt');
        @endphp
        @foreach ($sortedSections as $dynamicSection)
            <div class="notice-part">
                <a href="{{ url('/noticedetails') }}/{{ $dynamicSection['slug'] }}">
                    <h3>{{ $dynamicSection['title'] }}
                      
                    </h3>
                    <h3>{{ \Carbon\Carbon::parse($dynamicSection['createdAt'])->format('d M Y') }}</h3>
                </a>
                @if ($dynamicSection['createdAt'] >= now()->subDays(15)->endOfDay())
                    <button>new </button>
                @endif
            </div>
        @endforeach
    @endif
</div>

                        </div>
                    </div>
                </div>
            </section>
        @endif
    @endforeach
@endsection
