@extends('web.layouts.main')
@section('content')

   <main>
        <!--start single-blog-->
        <section class="single-blog">
            <div class="container">
                <div class="row">
                    <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                        <div class="card-news">
                            <div class="single-blog-carousel owl-carousel owl-theme">
                                <div class="item">
                                    <img src="{{asset($article->image)}}" alt="">
                                </div>
                               
                            </div>
                            <div class="card-header">
                                <h5>{{$article->name}}</h5>
                                <p class="date">
                                    <i class="far fa-clock"></i> {{date_format($article->created_at,"Y/m/d")}}
                                </p>
                               
                            </div>
                            <div class="card-body">
                                <p>
                                  {{$article->description}}
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
                        <div class="left-components">
                            <ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
                                <li class="nav-item" onclick="datablogs(0)" role="presentation">
                                    <a class="nav-link active" id="pills-tab1-tab" data-toggle="pill" href="#pills-tab1" role="tab" aria-controls="pills-tab1" aria-selected="true">الاحدث</a>
                                </li>
                                <li class="nav-item" role="presentation">
                                    <a class="nav-link" onclick="datablogs(1)" id="pills-tab2-tab" data-toggle="pill" href="#pills-tab2" role="tab" aria-controls="pills-tab2" aria-selected="false">الاشهر</a>
                                </li>
                                <li class="nav-item" role="presentation">
                                    <a class="nav-link" onclick="datablogs(2)" id="pills-tab3-tab" data-toggle="pill" href="#pills-tab3" role="tab" aria-controls="pills-tab3" aria-selected="false">المميز</a>
                                </li>
                            </ul>
                            <div class="tab-content" id="pills-tabContent">
                               <div class="tab-pane fade show active" id="pills-tab1" role="tabpanel" aria-labelledby="pills-tab1-tab">
                                    <div class="news-summary" id="datablogs">
                                        @foreach($articles as $row)
                                         <a href="{{url('blogs/'.$row->id)}}">
                                        <div class="item">
                                           
                                            <img src="{{asset($row->image)}}" alt="">
                                            <div class="text">
                                                <p>{{diff($row->created_at)}}</p>
                                                <h6> {{substr_replace($row->description,"...",120) }}</h6>
                                            </div>
                                          
                                        </div>
                                        </a>
                                      @endforeach
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-header">
                                <h6>تواصل معنا</h6>
                            </div>
                            <div class="card-body">
                                <div class="inner">
                                    <div class="item">
                                        <img src="{{url('')}}/web/images/icons/call.png" class="icon">
                                        <div class="text contact-text">
                                            <p class="title"><b>إتصل بنا</b></p>
                                            <p class="details">
                                                +12345678987
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <div class="inner">
                                    <div class="item">
                                        <img src="{{url('')}}/web/images/icons/email.png" class="icon">
                                        <div class="text contact-text">
                                            <p class="title"><b>البريد الالكتروني</b></p>
                                            <p class="details">
                                                mail@example.com
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <div class="inner">
                                    <div class="item">
                                        <img src="{{url('')}}/web/images/icons/location.png" class="icon">
                                        <div class="text contact-text">
                                            <p class="title"><b> العنوان</b></p>
                                            <p class="details">
                                                السعوديه - جده
                                            </p>
                                        </div>
                                    </div>
                                </div>


                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>
  

@push('js')
   <script>
      function datablogs(num){
        
         $.ajax({
          url : "{{url('datablogs')}}"+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#datablogs').html(data);
          }
        })
      }
   </script>
   @endpush
@stop