@extends('layouts.master')
@section('title', 'مطالب و اخبار')

@section('breadcrumb')
    <!-- start page title -->
    <div class="row">
        <div class="col-12">
            <div class="page-title-box">
                <div class="page-title-right">
                    <ol class="breadcrumb m-0">
                        <li class="breadcrumb-item"><a href="javascript: void(0);">پنل کاربری</a></li>
                        <li class="breadcrumb-item active">اخبار و سوالات متداول</li>
                    </ol>
                </div>
                <h4 class="page-title">اخبار و سوالات متداول</h4>
            </div>
        </div>
    </div>
    <!-- end page title -->
@endsection

@section('content')

    <div class="row">
        <div class="col">
            <div class="card-box">
                <div class="clearfix">
                    <div class="clearfix">
                        <div class="float-left">
                            <h4 class="header-title">لیست اخبار و سوالات متداول</h4>
                            <p class="sub-header">لیست تمامی مطالب به همراه اطلاعات</p>
                        </div>
                        <a href="{{ route('panel.posts.create') }}" class="btn btn-primary waves-effect waves-light float-right mb-3 text-white"><i class="remixicon-file-edit-line mr-2 align-middle"></i>افزودن</a>
                    </div>
                </div>
                @if(session('success'))
                    <div class="alert alert-success">{{ session('success') }}</div>
                @endif
                <div class="table-responsive">
                    <table class="table table-hover text-center">
                        <thead class="thead-light">
                            <tr>
                                <th>#</th>
                                <th>عنوان</th>
                                <th>نوع</th>
                                <th>وضعیت نمایش</th>
                                <th>تاریخ</th>
                                <th>گزینه ها</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($posts as $post)
                                <tr>
                                    <td>{{ $post->id }}</td>
                                    <td>{{ $post->title }}</td>
                                    <td>{!! post_type_label($post->type) !!}</td>
                                    <td>{!! post_status_label($post->status) !!}</td>
                                    <td>@jalali($post->created_at,Y-m-d)</td>
                                    <td>
                                        <a href="{{ route('panel.posts.edit', $post) }}" class="btn btn-secondary btn-xs">
                                            <span class="remixicon-file-edit-line "></span>
                                        </a>
                                        <a href="javascript:void(0)" class="btn btn-danger btn-xs" data-delete-url="{{ route('panel.posts.destroy', $post) }}">
                                            <span class="remixicon-file-reduce-line"></span>
                                        </a>
                                    </td>
                                </tr>
                            @empty
                                <td colspan="6" class="bg-light text-muted text-center">داده ای یافت نشد</td>
                            @endforelse
                        </tbody>
                    </table>
                </div>
                {{ $posts->links() }}
            </div>
        </div><!-- end col -->
    </div>

@endsection