@extends('backend.layouts.main')
@section('panel')
    <div class="row">
        <div class="col-lg-4">
            @if (Route::is('admin.settings.contact_edit'))
                <div class="card">
                    <div class="card-body">
                        <h4 class="card-title">Contact Edit</h4>
                        <form class="form p-t-20" method="POST" action="{{ route('admin.settings.update_contact',$contacts->id) }}" enctype="multipart/form-data">
                            @csrf
                            <div class="form-group mb-3">
                                <img class="input-group mb-3" style="width: 100px" src="{{ asset('uploads/' . $contacts->icon) }}">
                                <label>Icon</label>
                                <div class="input-group mb-3">
                                    <input type="file" name="icon" class="form-control" placeholder="Icon"
                                        required="" aria-label="Icon" aria-describedby="basic-addon11" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label>Title</label>
                                <div class="input-group mb-3">
                                    <input type="text" name="title" class="form-control" placeholder="Title"
                                        required="" aria-label="Title" aria-describedby="basic-addon11" value="{{ $contacts->title }}" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label>Url</label>
                                <div class="input-group mb-3">
                                    <input type="text" name="url" class="form-control"
                                        placeholder="Url" required="" aria-label="url"
                                        aria-describedby="basic-addon11" value="{{ $contacts->url }}" required>
                                </div>
                            </div>
                            <button type="submit" class="btn btn-primary m-r-10">Update</button>
                        </form>
                    </div>
                </div>
            @else
                <div class="card">
                    <div class="card-body">
                        <h4 class="card-title">Contact Create</h4>
                        <form class="form p-t-20" method="POST" action="{{ route('admin.settings.create_contact') }}" enctype="multipart/form-data">
                            @csrf
                            <div class="form-group mb-3">
                                <label>Icon</label>
                                <div class="input-group mb-3">
                                    <input type="file" name="icon" class="form-control" placeholder="Icon"
                                        required="" aria-label="Icon" aria-describedby="basic-addon11" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label>Title</label>
                                <div class="input-group mb-3">
                                    <input type="text" name="title" class="form-control" placeholder="Title"
                                        required="" aria-label="Title" aria-describedby="basic-addon11" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label>Url</label>
                                <div class="input-group mb-3">
                                    <input type="url" name="url" class="form-control"
                                        placeholder="Url" required="" aria-label="url"
                                        aria-describedby="basic-addon11" required>
                                </div>
                            </div>
                            <button type="submit" class="btn btn-primary m-r-10">Submit</button>
                        </form>
                    </div>
                </div>
            @endif
        </div>
        <div class="col-lg-8">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">Contact List</h4>
                </div>
                <div class="card-datatable table-responsive">
                    <table id="default-datatable" class="table table-bordered table-sm">
                        <thead>
                            <tr>
                                <th class="text-center" style="vertical-align: middle; font-size: 12px;">#</th>
                                <th class="text-center" style="vertical-align: middle; font-size: 12px;">Icon</th>
                                <th class="text-center" style="vertical-align: middle; font-size: 12px;">Title</th>
                                <th class="text-center" style="vertical-align: middle; font-size: 12px;">Url</th>
                                <th class="text-center" style="vertical-align: middle; font-size: 12px;">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($contact as $item)
                                <tr>
                                    <th class="text-center" style="vertical-align: middle; font-size: 13px;">{{ $loop->iteration }}</th>
                                    <td class="text-center" style="vertical-align: middle; white-space: normal; font-size: 13px;">
                                        <img class="container-fluid" style="width: 100px;" src="{{ asset('uploads/' . $item->icon) }}">
                                    </td>
                                    <td class="text-center"
                                        style="vertical-align: middle; white-space: normal; font-size: 13px;">{{ $item->title }}
                                    </td>
                                    <td class="text-center"
                                        style="vertical-align: middle; white-space: normal; font-size: 13px;">{{ $item->url }}
                                    </td>
                                    <td class="text-center" style="vertical-align: middle; font-size: 13px;">
                                        <a href="{{ route('admin.settings.contact_edit',$item->id) }}" class="btn btn-xs btn-primary"><span
                                                class="mdi mdi-pencil"></span></a>
                                        <a href="{{ route('admin.settings.contact_delete',$item->id) }}" class="btn btn-xs btn-danger"
                                            onclick="return confirm('Are you sure want to delete this contacts?');"><span
                                                class="mdi mdi-trash-can"></span></a>
                                    </td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
@endsection
