datatables where condition typesSum >= 20
datatables where condition typesSum >= 20
how to make typesSum >= 20
if(request()->ajax()) {
$model = Report::query()->select('report.', 'types_violations.', 'users.*', DB::raw('SUM(types_violations.sum_points) as typesSum'))
->join('types_violations', 'types_violations.id', '=', 'report.types_id')
->join('users', 'users.id', '=', 'report.user_id')
->where('report.status', 0)
->where('users.role', 0)
->groupBy('report.user_id')
// ->where('typesSum', 45)
->where('users.is_active', 1) // active account
// ->process()
->get();
return DataTables::of($model)->toJson();
File javascript
function load_data_filter_report()
{
$('#dataTableFilterReport').DataTable({
processing: true,
serverSide: true,
order: [[3, 'desc']],
language: {
lengthMenu: "Tampilkan MENU pelaporan per halaman",
zeroRecords: "Tidak ada yang ditemukan",
info: "Menampilkan halaman PAGE dari PAGES",
infoEmpty: "Tidak ada pelaporan yang tersedia",
infoFiltered: "(difilter dari MAX total data)"
},
ajax: {
url: /admin/filter-reports
,
},
columns: [
{
data: 'fullname',
name: 'fullname',
searchable: true,
},
{
data: 'email',
name: 'email',
searchable: true,
},
{
data: reporting_date
,
name: 'reporting_date'
},
{
data: typesSum
,
name: typesSum
},
]
});
}
Replies
->where('typesSum', 20, '>=')
https://editor.datatables.net/manual/php/conditions
Column not found: 1054 Unknown column 'typesSum' in
... change your query or your database design. Thanks.
The code you originally posted doesn't use the Editor PHP libraries we provide. It isn't clear to me which library it is using.
Allan