add status in opname datatable with order by created at desc
This commit is contained in:
@@ -20,7 +20,9 @@ class OpnamesController extends Controller
|
||||
public function index(Request $request){
|
||||
$menu = Menu::where('link','opnames.index')->first();
|
||||
if($request->ajax()){
|
||||
$data = Opname::with('user','dealer')->get();
|
||||
$data = Opname::with('user','dealer')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
return DataTables::of($data)
|
||||
->addColumn('user_name', function ($row){
|
||||
return $row->user ? $row->user->name : '-';
|
||||
@@ -31,6 +33,19 @@ class OpnamesController extends Controller
|
||||
->editColumn('opname_date', function ($row){
|
||||
return $row->opname_date ? Carbon::parse($row->opname_date)->format('d M Y') : '-';
|
||||
})
|
||||
->editColumn('created_at', function ($row) {
|
||||
return Carbon::parse($row->created_at)->format('d M Y H:i');
|
||||
})
|
||||
->editColumn('status', function ($row) {
|
||||
$statusClass = [
|
||||
'draft' => 'warning',
|
||||
'pending' => 'info',
|
||||
'approved' => 'success',
|
||||
'rejected' => 'danger'
|
||||
][$row->status] ?? 'secondary';
|
||||
|
||||
return '<span class="badge badge-' . $statusClass . '">' . ucfirst($row->status) . '</span>';
|
||||
})
|
||||
->addColumn('action', function ($row) use ($menu) {
|
||||
$btn = '<div class="d-flex">';
|
||||
|
||||
@@ -40,7 +55,7 @@ class OpnamesController extends Controller
|
||||
|
||||
return $btn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->rawColumns(['action', 'status'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user