File: /var/www/html/spion/resources/views/admin/template/index.blade.php
@extends('adminlte::page')
@include('admin.includes.datatable-axios-files')
@section('title', 'Templates')
@section('content_header')
<h1>Templates</h1>
<small>Manage Templates</small>
@stop
@section('content')
<div class="card card-dark">
<div class="card-header">
<div class="card-tools">
<a href="{{ route('template.create') }}" class="btn btn-dark"><i class="fas fa-plus"></i> Add Template</a>
</div>
</div>
<div class="card-body">
<form method="POST" id="search-form" role="form">
<div class="form-group">
<label for="search">Search</label>
<x-adminlte-input class="form-control" id="search_keyword" name="search_keyword"
placeholder="Enter Name"/>
</div>
<div class="form-group">
<label for="status">Status</label>
@php
$options = ['all' => 'All', 0 => 'Disabled', 1 => 'Active'];
@endphp
<x-adminlte-select name="status_filter" id="status_filter">
<x-adminlte-options :options="$options" empty-option="Select an option..."/>
</x-adminlte-select>
</div>
</form>
<table class="table table-bordered yajra-datatable">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Main Image</th>
<th>Screenshots</th>
<th>Tags</th>
<th>Features</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
@stop
@section('js')
<script type="text/javascript">
$(function () {
let table = $('.yajra-datatable').DataTable({
processing: true,
serverSide: true,
pageLength: 10,
searching: false,
ajax: {
url: "{{ route('template.index') }}",
data: function (data) {
data.search_keyword = $('#search_keyword').val();
data.status_filter = $('#status_filter').val();
}
},
columns: [
{data: 'title', name: 'title'},
{data: 'description', name: 'description'},
{
data: 'main_image',
name: 'main_image',
orderable: false,
searchable: false,
render: function (data) {
return data ? `<img src="${data}" width="50" height="50" alt="Main Image"/>` : 'No Image';
}
},
{
data: 'screenshots',
name: 'screenshots',
orderable: false,
searchable: false,
render: function (data) {
if (Array.isArray(data) && data.length > 0) {
return data.map(imgUrl => {
return `<img src="${imgUrl}" width="50" height="50" alt="Screenshot"/>`;
}).join(' ');
}
return 'No Screenshots';
}
},
{data: 'tags', name: 'tags'},
{data: 'features', name: 'features'},
{
data: 'status',
name: 'status',
render: function (data) {
return data ? 'Active' : 'Inactive';
}
},
{
data: 'action',
name: 'action',
orderable: false,
searchable: false
}
]
});
$('#search_keyword, #status_filter').on('change keyup', function () {
table.draw();
});
});
</script>
@stop