@extends('backend.admin.layouts.app')
@section('content')
    <div class="pagetitle">
        <h1>Dashboard</h1>
        <nav>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                <li class="breadcrumb-item">Dashboard</li>
                <li class="breadcrumb-item active">{{ $PageTitle }}</li>
            </ol>
        </nav>
    </div><!-- End Page Title -->

    <section class="section dashboard">

        <div class="row">
            <div class="col-lg-12">

                <div class="card">
                    <div class="card-body mt-3">
                        <a href="{{ route('admin.create-faq') }}"><button type="button" class="btn btn-primary">Add
                            FAQ</button></a>
                        <!-- Table with stripped rows -->
                        <table class="table table-striped mt-4">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th class="faquestion" scope="col">Question</th>
                                    <th scope="col">Answer</th>
                                    <th scope="col">Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($faqs as $faq)
                                    <tr>
                                        <th scope="row">{{ $loop->iteration }}</th>
                                        <td>{{ $faq->question }}</td>
                                        <td>{!! $faq->answer !!}</td>

                                        <td class="faqaction">
                                            <a href="{{ route('admin.faq.edit', $faq->id) }}" class="mr-1" title="Edit">
                                                <img src="{{ asset('assets/img/edit.png') }}" alt="">
                                            </a>

                                            <a href="#" class="ms-2 deleteItem"
                                                data-formid="delete_row_form_{{ $faq->id }}">
                                                <img src="{{ asset('assets/img/trash.png') }}" alt="">
                                            </a>
                                            <form action="{{ route('admin.faq.destroy', $faq->id) }}" method="post"
                                                id="delete_row_form_{{ $faq->id }}">
                                                @csrf
                                                {{ method_field('DELETE') }}
                                                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                            </form>
                                        </td>
                                    </tr>
                                @endforeach

                            </tbody>
                        </table>
                        <!-- End Table with stripped rows -->

                    </div>
                </div>
            </div>
        </div>

    </section>
@endsection
@push('style')
    <style>
        .faqaction {
            width: 100px;
        }

        .faquestion {
            width: 300px;
        }
    </style>
@endpush
