I'm trying to get date from $array[$i]
variable because $array[$i]
is giving me list of objects and I want just date from that object
for($i=0; $i<30; $i++){
$array[$i] = Carbon::now()->addDays(-$i);
$today_graph[$i] = payment::where('payment_date','=', $array[$i])->sum('amount');
}
Use $array[$i]->toDateString()
Or if you need time also you can use this $array[$i]->toDateTimeString()
Check docs here .
payment::whereDate('payment_date','=', $array[$i])->sum('amount');
https://laraveldaily.com/eloquent-date-filtering-wheredate-and-other-methods/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.