@extends('layouts.app_admin')
@section('title', 'Reviews')
@push('css')
@endpush

@section('content')

    <!-- Main Content -->
    <div class="main-content">
        <section class="section">

            <div class="col-12 section-header">
                <div class="col-6">
                    <h1>Reviews</h1>
                </div>


                <div class="col-6 d-flex flex-row-reverse">
                    <a class="btn btn-primary" href="{{ route('reviews.create') }}">
                        +Add New
                    </a>
                </div>
            </div>


            @if ($errors->any())
                <div class="col-sm-12">
                    <div class="alert  alert-warning alert-dismissible fade show" role="alert">
                        @foreach ($errors->all() as $error)
                            <span>
                                <p>{{ $error }}</p>
                            </span>
                        @endforeach
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                </div>
            @endif

            @include('flash-message')

            <div class="section-body">
                <div class="col-12">
                    <div class="card">
                        <div class="card-body p-0">
                            <div class="table-responsive">
                                <table id="example" class="table table-striped">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Name</th>
                                            {{-- <th>Date</th> --}}
                                            <th>Review</th>
                                            <th width="300px">Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        @foreach ($reviews as $key => $data)
                                            <tr>
                                                <td>{{ $key + 1 }}</td>
                                                <td>
                                                    @if ($data->name != null)
                                                        {{-- {!! \Illuminate\Support\Str::words($data->vision_text, 10,'....')  !!} --}}
                                                        {{ $data->name }}
                                                    @endif
                                                </td>
                                                {{-- <td>
                                                    @if ($data->created_at != null)
                                                   
                                                    {{ \Carbon\Carbon::parse($data->created_at)->format('l jS \of F Y') }}
                                                        

                                                    @endif
                                                </td> --}}

                                                <td>
                                                    @if ($data->rating != null)
                                                        {{ $data->rating }}
                                                    @endif
                                                </td>

                                                <td>



                                                    <a class="btn btn-info" href="{{ route('reviews.show', $data->id) }}">
                                                        Details
                                                    </a>



                                                    <a class="btn btn-primary edit"
                                                        href="{{ route('reviews.edit', $data->id) }}">
                                                        Edit
                                                    </a>

                                                    {{-- pending --}}
                                                    




                                                    <form method="POST" action="{{ route('reviews.destroy', $data->id) }}"
                                                        style="display:inline">
                                                        {{ method_field('DELETE') }}
                                                        {{ csrf_field() }}
                                                        <button type="submit" class=" btn-sm btn-danger"
                                                            onclick="return confirm('Confirm delete?')"><i
                                                                class="fa fa-trash-o" aria-hidden="true"></i>Delete

                                                        </button>
                                                    </form>
                                                </td>

                                            </tr>
                                        @endforeach

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

        </section>



    </div>

@endsection

@section('extra-js')
    <script></script>
@endsection
