api dashboard
This commit is contained in:
@@ -676,4 +676,23 @@ class CustomerController extends Controller
|
||||
|
||||
return response()->json($custcawangan);
|
||||
}
|
||||
|
||||
public function getTotalNewCustomerToday(){
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$harini = $current->toDateString();
|
||||
$lastweek = $current->subWeek()->toDateString();
|
||||
|
||||
$newcustomertoday = Customer::on('mysql7')->where('tarikhdaftar',$harini)->count();
|
||||
$newcustomerlastweek = Customer::on('mysql7')->where('tarikhdaftar',$lastweek)->count();
|
||||
|
||||
$diffCustomerPercent = 0;
|
||||
if($newcustomerlastweek != 0){
|
||||
$diffCustomerPercent = (($newcustomertoday - $newcustomerlastweek)/$newcustomerlastweek)*100;
|
||||
}
|
||||
$dataCustomer = [];
|
||||
array_push($dataCustomer,['newCustomerToday'=>$newcustomertoday,'percentDiff'=>$diffCustomerPercent]);
|
||||
|
||||
return response()->json($dataCustomer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user