app/Models/Transaction.php
/**
     * Get Datatable Data for Admin
     * @return array
     */
Get Datatable Data for Admin
@return array
Get Datatable Data for Admin @return array
public function datatableForAdmin()
    {
        $results = $this->with(['user', 'details'])->orderBy('number', 'desc')->get();
        return Datatables::of($results)
             ->editColumn('number', function ($data) {
                $html = '<a class="btn-admin-preview-transactions" data-id="'. $data->id .'">'. $data->number .'</a>';
                return $html;
            })
            ->editColumn('created_at', function ($data) {
                return date('l, d F Y - H:i', strtotime($data->created_at));
            })
            ->editColumn('total', function ($data) {
                return 'Rp '. number_format($data->total,0,',','.');
            })
            ->editColumn('status', function ($data) {
                return strtoupper($data->status);
            })
            ->editColumn('is_paid', function ($data) {
                if($data->is_paid == 1) {
                    $html = '<span class="text-success">Terverifikasi</span>';
                } else if(empty($data->proof)) {
                    $html = '<span class="text-danger">Belum dibayar</span>';
                } else {
                    $html = '<span class="text-warning">Menunggu verifikasi penjual</span>';
                }
                return $html;
            })
            ->editColumn('action', function ($data) {
                $html = '
                <button id="adminButtonModalTransactions" class="btn btn-danger btn-admin-transactions btn-icon" proof="' . (!empty($data->proof) ? asset($data->proof) : '') . '" is-paid="' . $data->is_paid . '" transaction-number="' . $data->number . '" status="' . $data->status . '" data-id="' . $data->id .'">
                    Ubah Status
                </button>';
                return $data->status == 'selesai' ? '' : $html;
            })
            ->rawColumns(['number','is_paid', 'action'])
            ->make(true);
    }
public function datatableForAdmin ( ) { $ results = $ this -> with ( [ 'user' , 'details' ] ) -> orderBy ( 'number' , 'desc' ) -> get ( ) ; return Datatables :: of ( $ results ) -> editColumn ( 'number' , function ( $ data ) { $ html = '<a class="btn-admin-preview-transactions" data-id="' . $ data -> id . '">' . $ data -> number . '</a>' ; return $ html ; } ) -> editColumn ( 'created_at' , function ( $ data ) { return date ( 'l, d F Y - H:i' , strtotime ( $ data -> created_at ) ) ; } ) -> editColumn ( 'total' , function ( $ data ) { return 'Rp ' . number_format ( $ data -> total , 0 , ',' , '.' ) ; } ) -> editColumn ( 'status' , function ( $ data ) { return strtoupper ( $ data -> status ) ; } ) -> editColumn ( 'is_paid' , function ( $ data ) { if ( $ data -> is_paid == 1 ) { $ html = '<span class="text-success">Terverifikasi</span>' ; } else if ( empty ( $ data -> proof ) ) { $ html = '<span class="text-danger">Belum dibayar</span>' ; } else { $ html = '<span class="text-warning">Menunggu verifikasi penjual</span>' ; } return $ html ; } ) -> editColumn ( 'action' , function ( $ data ) { $ html = '
                <button id="adminButtonModalTransactions" class="btn btn-danger btn-admin-transactions btn-icon" proof="' . ( ! empty ( $ data -> proof ) ? asset ( $ data -> proof ) : '' ) . '" is-paid="' . $ data -> is_paid . '" transaction-number="' . $ data -> number . '" status="' . $ data -> status . '" data-id="' . $ data -> id . '">
                    Ubah Status
                </button>' ; return $ data -> status == 'selesai' ? '' : $ html ; } ) -> rawColumns ( [ 'number' , 'is_paid' , 'action' ] ) -> make ( true ) ; }
Get Datatable Data for Admin
 @return array
Get Datatable Data for Admin @return array