我想将数据库表存储在数据表中吗?
我的控制器
$tablemonth = \DB::select("SHOW TABLES WHERE Tables_in_database LIKE '%Month_Report_%'");
我的没有数据表的刀片服务器
<table id="listoftable" class="table table-bordered">
<thead class="thead-dark">
<tr>
<th>File Name</th>
</tr>
</thead>
<tbody>
@foreach($tablemonth as $table)
<tr>
<td>
{{$table->Tables_in_database}}
</td>
</tr>
@endforeach
</tbody>
</table>
试图做到这一点
<script>
$(function() {
var table = $('#listoftable').DataTable({
processing: false,
serverSide: true,
ajax: '{!! route('admin.get.table') !!}',
columns: [
{ data: {{tablemonth}}, name: {{$tablemonth}} },
]
});
});
</script>
数据库表
答案 0 :(得分:1)
我建议调查https://github.com/yajra/laravel-datatables,该方法允许将以下结果用作数据表的输入:
$data = \DB::select("SHOW TABLES WHERE Tables_in_database LIKE '%Month_Report_%'");
return Datatables::of($data)->addIndexColumn()->make(true);
使用上面的代码段创建一个控制器,并通过以下DataTables初始化使用它:
<script>
$(function() {
$('#listoftable').DataTable({
processing: true,
serverSide: true,
ajax: '{{ route('API-route-name') }}',
columns: [
{ data: 'Tables_in_database', name: 'Table name' }
]
});
});
</script>
有关教程,请参见https://www.itsolutionstuff.com/post/laravel-58-datatables-tutorialexample.html。