src/Controllers/TicketsController.php
public function monthlyPerfomance($period = 2)
    {
        $categories = Category::all();
        foreach ($categories as $cat) {
            $records['categories'][] = $cat->name;
        }

        for ($m = $period; $m >= 0; $m--) {
            $from = Carbon::now();
            $from->day = 1;
            $from->subMonth($m);
            $to = Carbon::now();
            $to->day = 1;
            $to->subMonth($m);
            $to->endOfMonth();
            $records['interval'][$from->format('F Y')] = [];
            foreach ($categories as $cat) {
                $records['interval'][$from->format('F Y')][] = round($this->intervalPerformance($from, $to, $cat->id), 1);
            }
        }

        return $records;
    }
public function monthlyPerfomance($period = 2)
    {
        $categories = Category::all();
        foreach ($categories as $cat) {
            $records['categories'][] = $cat->name;
        }

        for ($m = $period; $m >= 0; $m--) {
            $from = Carbon::now();
            $from->day = 1;
            $from->subMonth($m);
            $to = Carbon::now();
            $to->day = 1;
            $to->subMonth($m);
            $to->endOfMonth();
            $records['interval'][$from->format('F Y')] = [];
            foreach ($categories as $cat) {
                $records['interval'][$from->format('F Y')][] = round($this->intervalPerformance($from, $to, $cat->id), 1);
            }
        }

        return $records;
    }
public function monthlyPerfomance ( $ period = 2 ) { $ categories = Category :: all ( ) ; foreach ( $ categories as $ cat ) { $ records [ 'categories' ] [ ] = $ cat -> name ; } for ( $ m = $ period ; $ m >= 0 ; $ m -- ) { $ from = Carbon :: now ( ) ; $ from -> day = 1 ; $ from -> subMonth ( $ m ) ; $ to = Carbon :: now ( ) ; $ to -> day = 1 ; $ to -> subMonth ( $ m ) ; $ to -> endOfMonth ( ) ; $ records [ 'interval' ] [ $ from -> format ( 'F Y' ) ] = [ ] ; foreach ( $ categories as $ cat ) { $ records [ 'interval' ] [ $ from -> format ( 'F Y' ) ] [ ] = round ( $ this -> intervalPerformance ( $ from , $ to , $ cat -> id ) , 1 ) ; } } return $ records ; }
Calculate average closing period of days per category for number of months.

@param int $period

@return \Illuminate\Database\Eloquent\Collection|static[]
Calculate average closing period of days per category for number of months .