AuditController.php
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace App\Http\Controllers\Backend;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Yajra\DataTables\Facades\DataTables;
use OwenIt\Auditing\Models\Audit;
use App\Models\Provinsi;
class AuditController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('backend.audit.index');
}
public function data(Request $request)
{
if ($request->ajax()) {
$audit = Audit::with('user')->orderBy('created_at', 'desc')->get();
return Datatables::of($audit)
->addIndexColumn()
->addColumn(
'username',
function ($audit) {
return $audit->user->username;
}
)
->addColumn(
'time',
function ($audit) {
return date('Y-m-d H:i:s', strtotime($audit->created_at));
}
)
->rawColumns(['username','time'])->make(true);
} else {
exit("Not an AJAX request -_-");
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$audit = \OwenIt\Auditing\Models\Audit::find($id);
return view('backend.audit.index', compact('audit'));
}
//
public function indexOld()
{
$audits = \OwenIt\Auditing\Models\Audit::with('user')
->orderBy('created_at', 'desc')->get();
return view('backend.audit.record', ['audits' => $audits]);
}
}