php last 12 month for Carbon

mail@pastecode.io avatar
unknown
php
2 years ago
466 B
1
Indexable
Never
    public function last_carbon_month()
    {
        for ($i=0; $i <= 12 ; $i++) { 
            $last_month[$i] = new \stdClass;
            $last_month[$i]->date = Carbon::now()->subMonth($i)->isoFormat('Do.MM.YYYY');
            $last_month[$i]->text = Carbon::now()->subMonth($i)->isoFormat('Do MMM YYYY');
            $last_month[$i]->payments = "elma";
        }
        return Response::withData(true, 'last 12 mounth successfully listed', $last_month);
    }