Monday 21 August 2017

Multiple Count With Case Condition IN Mysql Laravel

Here is the code for Multiple Count With Case Condition IN Mysql Laravel :

public function piechartdata()
{
$orders = Order::select(
DB::raw("
COUNT(CASE status WHEN '1' THEN 'OrderPlaced' ELSE NULL END) as OrderPlaced,
COUNT(CASE status WHEN '3' THEN 'Rejected' ELSE NULL END) as Rejected,
COUNT(CASE status WHEN '4' THEN 'Failure' ELSE NULL END) as Failure,
COUNT(CASE status WHEN '6' THEN 'Delivered' ELSE NULL END) as Delivered")
)

->where('orders.active', 1)
->orderBy('id','desc')
->get();

return response()->json(['data' => $orders], 200);

}

Solved : Chartjs Bar Chart showing old data when hovering

Here is the Solved code for Chartjs Bar Chart showing old data when hovering:

var ctxLine = document.getElementById("line-chart").getContext("2d");

if(window.bar != undefined)
window.bar.destroy();
window.bar = new Chart(ctxLine, {});

Custom Button Click Function To Refresh Datatable Record Without Page load

Here is the code for Custom Button Click Function To Refresh Datatable Record Without Page load:

$(document).on("click", '.refreshRecords', function (e) {
$('#dTableOrder').DataTable().ajax.reload(null, true);
});

Google Map Filter Api Example

Here is Google Map Filter Api Example: