@extends('master')
@section('content')
    {{-- <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Dashboard') }}
        </h2>
    </x-slot> --}}


            @if (session()->has('message'))
                <div class="alert alert-icon-right alert-success alert-dismissible mt-2" role="alert">
                    <span class="alert-icon">
                        <i class="la la-info"></i>
                    </span>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <strong>{{ session('message') }}</strong>
                </div>
            @endif
 <section class="banner bg-img-none">
    <img src="{{ asset('img/frontend/banner-news.jpg') }}" alt="Banner image">
    <div class="banner-content">
      <div class="container">
        <div class="row">
          <div class="col-12">
            <h1>Latest News & Development</h1>
          </div>
        </div>
      </div>
    </div>
  </section>           
 <section class="news pt-5">
    <div class="container">
      <div class="row text-left">
        <div class="col-12">
          <div class="btn-sec"><a class="bck-btn" href="{{url('news')}}">Back</a></div>
        </div>
        <div class="col-lg-9 col-md-12 col-sm-12 news-left pr-lg-5 pr-md-2">
          <h2>{{$news->title}} </h2>
         <h6 class="mb-4">@if(isset($news->date) && !empty($news->date)){{date('d M Y', strtotime($news->date))}} @else -- @endif by <span>@if(isset($news->author) && !empty($news->author)) {{$news->author}} @else -- @endif</span></h6>
          @if($news->image_path != '')
                <img class="w-100" src="{{$path.$news->image_path}}" alt="">
          @endif
          <p class="pt-3">{!!$news->description!!}</p>
            
        </div>
        <div class="col-lg-3 col-md-12 col-sm-12 news-right pl-lg-3 pl-md-auto pt-5 pt-lg-0">
                <div class="newsRightSec">
                <form method="get" action="{{ url('newssearch') }}" id ="searchNews" class="edit-form" enctype="multipart/form-data">
                  <div class="newsSearch">
                    <div class="input-group">
                      <input type="search" name="newsSearch" id="newsSearch" class="form-control border-0" placeholder="Search" aria-label="Search"aria-describedby="search-addon" />
                      <span class="input-group-text border-0" id="search-addon">
                        <svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
                          <path
                            d="M14 14L21 21L14 14ZM8.5 16C10.4891 16 12.3968 15.2098 13.8033 13.8033C15.2098 12.3968 16 10.4891 16 8.5C16 6.51088 15.2098 4.60322 13.8033 3.1967C12.3968 1.79018 10.4891 1 8.5 1C6.51088 1 4.60322 1.79018 3.1967 3.1967C1.79018 4.60322 1 6.51088 1 8.5C1 10.4891 1.79018 12.3968 3.1967 13.8033C4.60322 15.2098 6.51088 16 8.5 16V16Z"
                            stroke="#495057" stroke-width="2" />
                        </svg>
                      </span>
                    </div>
                  </div>
              </form>
             
                  <div class="news-cat py-5">
                    <h5 class="pb-2">News</h5>
                    
                    <div id="accordion">
                       <div class="card">
                      <?php  $count = 1; ?>
                      @if(!empty($archivedNews))
                      @foreach($archivedNews as $year => $archived)
                     
                        <div class="card-header" id="headingOne">
                          <h5 class="mb-0">

                            <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne_{{$count}}"
                              aria-expanded="true" aria-controls="collapseOne">
                              <p>{{$year}}</p>
                              </button>
                          </h5>
                        </div>

                        <div id="collapseOne_{{$count}}" class="collapse " aria-labelledby="headingOne" data-parent="#accordion">
                          <div class="card-body">

                             @foreach($archived as $month => $mn)
                             <div class="historySec">
                                <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne_{{$count}}"
                                  aria-expanded="true" aria-controls="collapseOne">
                                  {{$month}}<span>({{count($mn)}})</span>
                                </button>
                                <ul>
                                  @foreach($mn as $key => $news)
                                  <li><span>{{date('d M Y', strtotime($news->date))}} </span><a href="{{url('newsdetails/'.$news->id)}}"><p class="text-truncate">{{$news->title}}</p></a></li>
                                  @endforeach
                                </ul>
                              </div>
                              @endforeach
                          </div>
                        </div>
                         <?php $count++; ?>
                            @endforeach
                            @endif
                      </div>
                    </div>


                  </div>
                </div>

              </div>
            </div>
          </div>
        </section>
 @stop       