src/Controllers/TicketsController.php
public function intervalPerformance($from, $to, $cat_id = false)
    {
        if ($cat_id) {
            $tickets = Ticket::where('category_id', $cat_id)->whereBetween('completed_at', [$from, $to])->get();
        } else {
            $tickets = Ticket::whereBetween('completed_at', [$from, $to])->get();
        }

        if (empty($tickets->first())) {
            return false;
        }

        $performance_count = 0;
        $counter = 0;
        foreach ($tickets as $ticket) {
            $performance_count += $this->ticketPerformance($ticket);
            $counter++;
        }
        $performance_average = $performance_count / $counter;

        return $performance_average;
    }
public function intervalPerformance($from, $to, $cat_id = false)
    {
        if ($cat_id) {
            $tickets = Ticket::where('category_id', $cat_id)->whereBetween('completed_at', [$from, $to])->get();
        } else {
            $tickets = Ticket::whereBetween('completed_at', [$from, $to])->get();
        }

        if (empty($tickets->first())) {
            return false;
        }

        $performance_count = 0;
        $counter = 0;
        foreach ($tickets as $ticket) {
            $performance_count += $this->ticketPerformance($ticket);
            $counter++;
        }
        $performance_average = $performance_count / $counter;

        return $performance_average;
    }
public function intervalPerformance ( $ from , $ to , $ cat_id = false ) { if ( $ cat_id ) { $ tickets = Ticket :: where ( 'category_id' , $ cat_id ) -> whereBetween ( 'completed_at' , [ $ from , $ to ] ) -> get ( ) ; } else { $ tickets = Ticket :: whereBetween ( 'completed_at' , [ $ from , $ to ] ) -> get ( ) ; } if ( empty ( $ tickets -> first ( ) ) ) { return false ; } $ performance_count = 0 ; $ counter = 0 ; foreach ( $ tickets as $ ticket ) { $ performance_count += $ this -> ticketPerformance ( $ ticket ) ; $ counter ++ ; } $ performance_average = $ performance_count / $ counter ; return $ performance_average ; }
Calculate the average date length it took to solve tickets within date period.

@param $from
@param $to

@return int
Calculate the average date length it took to solve tickets within date period .