Amigos, estoy tratando de integrar datatables en mi proyecto con el siguiente código.
Controller
use Yajra\DataTables\DataTables;
class varController extends Controller
{
public function index(Request $request)
{
$var = Var::select(['id']);
return Datatables::of($var)->make(true);
}
}
Ruta
Route::resource('variab/var','VarController');
Vista
@extends ('layouts.var')
@section ('content')
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<title>Laravel DataTables</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/plugin/datatables/dataTables.bootstrap.css">
<link rel="stylesheet" href="css/plugin/datatables/dataTables.bootstrap.min.css">
<script src="js/libs/jquery/jquery-2.1.4.min.js"></script>
<script src="js/plugin/datatables/jquery.dataTables.min.js"></script>
<script src="js/plugin/datatables/dataTables.bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<table id="appointment-datatable" class="table table-hover table-condensed">
<thead>
<tr>
<th>Id</th>
</tr>
</thead>
</table>
</div>
</body>
@endsection
<script type="text/javascript">
$(document).ready(function(){
oTable = $('#appointment-datatable').DataTable({
"processing": true,
"serverSide": true,
"ajax": "{{ route('appointments') }}",
"columns": [
{data: 'id', name: 'id'},
]
});
});
</script>
Resultados
"draw":0,"recordsTotal":167,"recordsFiltered":167,"data":[{"id":25},{"id":17},{"id":47},{"ida":122},{"id":114},{"id":40},{"id":110},{"id":134},{"id":135},{"id":27},{"id":21},{"id":133},{"id":150}, count_row_table","bindings":[],"time":"1"},{"query":"select
var
fromvari
","bindings":[],"time":"1"}],"input":[]}
Composer.json
"require": {
"yajra/laravel-datatables-oracle": "~9.0"
},
Pero no salen dentro del marco los resultados ni dentro de la tabla. ¿Cómo haría para que me tome la datatable? Gracias de antemano por la ayuda que pudieran brindarme.