Last active
October 11, 2022 16:48
-
-
Save faridfr/a4f40bba52913219408397360c88bdd9 to your computer and use it in GitHub Desktop.
Monthly Chart Back End Laravel With Jalali Dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$results['x'] = []; | |
$results['y'] = []; | |
$results['xy'] = []; | |
for($i=30;$i>=0;$i--) | |
{ | |
$x = date('Y-m-d',strtotime('-'.$i.' days')); | |
$y = Order::where('created_at','like','%'.$x.'%') | |
->where('store_id',$storeId) | |
->count('id'); | |
// You can use whereDate('created_at','=',$x) | |
// Calculate data here and change the value of X and Y ... | |
$jalali = jdate($x)->format('Y-m-d'); | |
array_push($results['y'],$y); | |
array_push($results['xy'],["x"=>$jalali,"y"=>$y]); | |
array_push($results['x'],$jalali); | |
} | |
return [ | |
'xAxis' => $results['x'], | |
'yAxis' => $results['y'], | |
'xy' => $results['xy'], | |
]; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment