@extends('admin.layouts.app')

@section('content')


@if (session('notification_create_msg'))
<div class="alert alert-success">
    {{ session('notification_create_msg') }}
</div>
@endif

@if (session('notification_delete_msg'))
<div class="alert alert-danger">
    {{ session('notification_delete_msg') }}
</div>
@endif



<h2 class="mb-3">{{awtTrans('All Notifications')}}</h2>

<div class="card shadow mb-4">
    <div class="card-header py-3">
        <h6 class="m-0 font-weight-bold text-primary text-left">
            <button type="submit" style="display: none;" title="{{ awtTrans('delete') }}" class="btn btn-danger bluck-button btn-circle btn-sm">
                <i class="fas fa-trash"></i>
            </button>
            <a href="{{ route('admin.notifications.create') }}" title="{{ awtTrans('add') }}" class="btn btn-primary btn-circle btn-sm">
                <i class="fas fa-plus"></i>
            </a>
        </h6>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-bordered table-striped" id="dataTablenotifications" width="100%" cellspacing="0">
                <thead>
                    <tr>
                        <th>{{ awtTrans('Delete') }}</th>
                        <th>{{ awtTrans('Title Arabic') }}</th>
                        <th>{{ awtTrans('Title English') }}</th>
                        <th>{{ awtTrans('Description Arabic') }}</th>
                        <th>{{ awtTrans('Description English') }}</th>
                        <th>{{ awtTrans('Image') }}</th>
                        <th>{{ awtTrans('Created At') }} </th>
                        <th>{{ awtTrans('Actions') }} </th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th>{{ awtTrans('Delete') }}</th>
                        <th>{{ awtTrans('Title Arabic') }}</th>
                        <th>{{ awtTrans('Title English') }}</th>
                        <th>{{ awtTrans('Description Arabic') }}</th>
                        <th>{{ awtTrans('Description English') }}</th>
                        <th>{{ awtTrans('Image') }}</th>
                        <th>{{ awtTrans('Created At') }} </th>
                        <th>{{ awtTrans('Actions') }} </th>
                    </tr>
                </tfoot>
                <tbody>
                    @if (!empty($notifications))
                    @foreach ($notifications as $notification)
                    <tr>
                        <td><input type="checkbox" name="ids[]" value="{{ $notification->id }}" class="from-control bluck-delete"> </td>
                        <td>{{ $notification->title_ar }}</td>
                        <td>{{ $notification->title_en }}</td>
                        <td>{{ strip_tags($notification->message_ar) }}</td>
                        <td>{{ strip_tags($notification->message_en) }}</td>
                        <td><img height="44" src="{{  $notification->image }}" alt=""></td>
                        <td>{{ $notification->created_at->diffForHumans() }}</td>
                        <td>
                            <a href=" {{ route('admin.notifications.destroy', $notification->id) }}" data-id="{{$notification->id}}" class="btn btn-danger btn-circle btn-sm item-delete">
                                <i class="fas fa-trash"></i>
                            </a>
                        </td>
                    </tr>

                    @endforeach
                    @endif
                </tbody>
            </table>
        </div>
    </div>
</div>


@endsection

@section('scripts')
<script>
    $(document).ready(function() {
        $('#dataTablenotifications').DataTable({
            order: [0, 'desc'],
            'language': {
                'url': "{{ app()->getLocale() == 'ar' ? 'https://cdn.datatables.net/plug-ins/1.10.12/i18n/Arabic.json' : 'https://cdn.datatables.net/plug-ins/1.10.12/i18n/English.json' }}",
            },
        });
    });
</script>
@endsection