@extends('admin.master')
@section('title') ব্লগ | SHOP @endsection
@section('blog') active @endsection
@section('blog.index') active @endsection
@section('styles')
@endsection


@section('main_content_section')
<div class="row py-3 ps-2">
    <div class="heading d-flex justify-content-start align-items-center">
        <h3 class="mb-0"><span> ব্লগের তালিকা</span></h3>
    </div>
</div>

<div class="table_wrapper py-1 card">
    <div class="row my-2 aggregate-section-div">
        <div class="px-3 ">
            <div class=" d-flex justify-content-between align-items-center aggregate-section border">
                <div class="d-flex align-items-center">
                    <p class="mb-0"><a href="{{route('blog.index')}}"
                            class="text-primary py-2 px-3">সব({{$allBlogCount}})</a>
                    </p>

                    <p class="mb-0"><a href="{{route('active-blog-list')}}"
                            class="text-primary py-2 px-3">সক্রিয়({{$activeBlogCount}})</a></p>
                    <p class="mb-0"><a href="{{route('inactive-blog-list')}}"
                            class="text-primary py-2 px-3 active">নিষ্ক্রিয়({{$blogs->count()}})</a></p>
                </div>
                <div class="d-none d-sm-block">
                    @if (Auth::user()->can('blog-create')) 
                        <a href="{{route('blog.create')}}"
                            class="btn btn-success rounded-0 d-flex align-items-center px-2 border-0"><span class="">নতুন
                                ব্লগ</span></a>
                    @endif
                </div>
            </div>

            @if (Auth::user()->can('blog-create')) 
                <div class="mt-2 btn btn-success d-block rounded-0 d-sm-none">
                    <a class="text-white" href="{{route('blog.create')}}">নতুন ব্লগ</a>
                </div>
            @endif
        </div>
    </div>



    <div class="row px-3">
        <div class="table-container table-responsive">
            <table id="" class="table table-bordered">
                <thead class="text-uppercase">
                    <tr class="me-3">
                        <th class="text-center" scope="col"><span>ব্লগের ছবি</span></th>
                        <th class="text-center" scope="col"><span>ব্লগের বিস্তারিত</span></th>
                        <th class="text-center" scope="col"><span>আইডি</span></th>
                        <th class="text-center" scope="col"><span>বর্তমান অবস্থা</span></th>
                    </tr>
                </thead>
                <tbody class="text-center">

                    @foreach($blogs as $key=>$item)
                    @if(isset($item) && $item != null)
                    <tr class="">

                        <td>
                            <div class="row_title">
                                @if($item->photo != null)
                                <img src="{{asset('uploads/blog_img/'.$item->photo)}}" height="100" width="100" alt="">
                                @else
                                <img src="#" height="100" width="100" alt="">
                                @endif
                            </div>
                            <div class="row-actions">
                                @if (Auth::user()->can('blog-edit')) 
                                    <span><button class="edit_class_modal border-0 bg-transparent" value="{{ $item->id }}">
                                            <a href="{{route('blog.edit', $item->id)}}">সম্পাদন</a> </button> | </span>
                                @endif

                                @if (Auth::user()->can('blog-delete')) 
                                    <span><a href="{{ route('blog.delete', ['id'=>$item->id]) }}" class="row-delete"><span
                                                class="trash text-danger">ডিলিট</span> | </a></span>
                                @endif

                                @if($item->status == true)
                                <span><a class="text-warning"
                                        href="{{route('blog.inactive', $item->id)}}">নিস্ক্রিয়</a></span>
                                @else
                                <span><a class="text-success"
                                        href="{{route('blog.active', $item->id)}}">সক্রিয়</a></span>
                                @endif
                            </div>
                        </td>

                        <td class="custom-text-left">
                            <b>টাইটেল: </b> <span>{{$item->title}} </span><br>
                            <b>ডিস্ক্রিপশন: </b><span>{{Str::limit($item->solid_post, 100)}} </span>
                        </td>

                        <td>
                            <b>{{$item->id}}</b>
                        </td>

                        <td>
                            @if($item->status == true)
                            <span class="badge bg-success">সক্রিয়</span>
                            @else
                            <span class="badge bg-danger">নিষ্ক্রিয়</span>
                            @endif
                        </td>

                    </tr>
                    @endif
                    @endforeach


                </tbody>
            </table>
        </div>

        <div class="clearfix d-flex">
            <div class="float-left">
                <p class="text-muted">
                    {{ __('Showing') }}
                    <span class="font-weight-bold">{{ $blogs->firstItem() }}</span>
                    {{ __('to') }}
                    <span class="font-weight-bold">{{ $blogs->lastItem() }}</span>
                    {{ __('of') }}
                    <span class="font-weight-bold">{{ $blogs->total() }}</span>
                    {{ __('results') }}
                </p>
            </div>

            <div class="float-right custom-table-pagination">
                {!! $blogs->links('pagination::bootstrap-4') !!}
            </div>
        </div>
    </div>


</div>
@endsection

@section('scripts')
@endsection