As the title suggests, I am implementing server-side datatable.
I am having a problem with the global search to read birthDate in dd/mm/yy format.
I can only read the date in y-m-d format (i.e. the default date of the db).
This is my code:
// get data from user_dummies table
$query = DB::table('user_dummies')->select('*');
// Global Search
$search = $request->search;
$query = $query->where(function ($query) use ($search) {
$query->orWhere('firstName', 'like', "%" . $search . "%");
$query->orWhere('lastName', 'like', "%" . $search . "%");
$query->orWhere('age', 'like', "%" . $search . "%");
$query->orWhere('birthDate', 'like', "%" . $search . "%");
$query->orWhere('role', 'like', "%" . $search . "%");
});
I tried to write the code corresponding to the birthDate put below but I get an error from datatable,
i.e. DataTables warning: table id=datatable – Ajax error.
$query->orWhere(date('d/m/y',strtotime('birthDate')), 'like', "%" . $search . "%");
Can someone tell me how to do this?