So, this is my controller:
use Yajra\DataTables\Facades\DataTables;
class CategoriasController extends Controller
{
public function index()
{
return Datatables::collection(Categoria::all())->make(true);
}
[...]
}
this is my route:
Route::group(['middleware' => 'auth'], function () {
Route::group(['middleware' => 'admin'], function () {
Route::prefix('admin')->namespace('Admin')->group(function () {
Route::prefix('categorias')->group(function(){
Route::get('/', 'CategoriasController@index')->name('curso.index');
[...]
});
});
});
});
and this is my blade:
[...]
<div class="container">
<table class="table border" id="myTable">
<thead>
<tr>
<th>id</th>
<th>Nome</th>
<th>Criado</th>
<th>Modificado</th>
</tr>
</thead>
</table>
</div>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready( function () {
$('#myTable').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route('categoria.index') !!}',
columns: [
{ data: 'id', name:'id'},
{ data: 'nome', name:'nome'},
{ data: 'created_at', name:'created_at'},
{ data: 'updated_at', name:'updated_at'},
]
});
} );
</script>
[...]
And I got this as a return: Print
I'm using Laravel 5.8.19
composer.json
[...]
"require":{
"yajra/laravel-datatables": "^1.5",
"yajra/laravel-datatables-oracle": "~9.0"
}
So why is not a table rendering? Is it something I'm doing wrong? I ran the internet and I did not find a solution, I hope you will help me
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2wxPyqk
via IFTTT
Aucun commentaire:
Enregistrer un commentaire