@extends('layouts.app_admin')
@section('title', 'Services')
@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>Services</h1>
                </div>


                <div class="col-6 d-flex flex-row-reverse">
                    <a class="btn btn-primary" href="{{ route('service.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>Service Name</th>
                                            <th width="300px">Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        @foreach ($services as $key => $data)
                                            <tr>
                                                <td>{{ $key + 1 }}</td>
                                                <td>
                                                    @if ($data->title != null)
                                                        {{-- {!! \Illuminate\Support\Str::words($data->vision_text, 10,'....')  !!} --}}
                                                        {{ $data->title }}
                                                    @endif
                                                </td>

                                                <td>

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

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

                                                    <form method="POST" action="{{ route('service.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
