Untitled

 avatar
user_4626843
plain_text
7 months ago
1.2 kB
4
Indexable
Never
ROUTE
Route::resource('/reports', \App\Http\Controllers\ReportController::class);
Route::get('/reports', [\App\Http\Controllers\ReportController::class,'index'])->name('reports.index');

CONTROLLER
public function index(Request $request)
{
    if ($request->ajax()) {
        $data = Report::query(); // Gantilah ini dengan kueri Anda sesuai dengan model Report Anda.

        return DataTables::of($data);
    }

    return view('reports.index'); // Gantilah "reports.index" dengan nama tampilan yang sesuai.
}

AJAX
<script type="text/javascript">
$(function () {

var table = $('.kunyuk').DataTable({
    processing: true,
    serverSide: true,
    ajax: "{{ route('reports.index') }}",
    columns: [
        { data: 'id', name: 'id' },
        { data: 'tanggal', name: 'tanggal' },
        { data: 'nama_user', name: 'nama_user' },
        { data: 'kegiatan', name: 'kegiatan' },
        { data: 'tantangan', name: 'tantangan' },
        { data: 'solusi', name: 'solusi' },
        { data: 'status', name: 'status' },
        { data: 'catatan', name: 'catatan' },
        { data: 'action', name: 'action', orderable: false, searchable: false },
    ]
});

});