original_string: protected function getIncidents()
      {
          $allIncidents = Incident::whereBetween('occurred_at', [
              $this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
              $this->startDate->format('Y-m-d').' 23:59:59',
          ])->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) {
              return (new Date($incident->occurred_at))
                  ->setTimezone($this->dateTimeZone)->toDateString();
          });
  
          // Add in days that have no incidents
          foreach (range(0, 30) as $i) {
              $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);
  
              if (!isset($allIncidents[$date->toDateString()])) {
                  $allIncidents[$date->toDateString()] = [];
              }
          }
  
          // Sort the array so it takes into account the added days
          $allIncidents = $allIncidents->sortBy(function ($value, $key) {
              return strtotime($key);
          }, SORT_REGULAR, false);
  
          return $allIncidents;
      }
code: protected function getIncidents()
      {
          $allIncidents = Incident::whereBetween('occurred_at', [
              $this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
              $this->startDate->format('Y-m-d').' 23:59:59',
          ])->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) {
              return (new Date($incident->occurred_at))
                  ->setTimezone($this->dateTimeZone)->toDateString();
          });
  
          // Add in days that have no incidents
          foreach (range(0, 30) as $i) {
              $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);
  
              if (!isset($allIncidents[$date->toDateString()])) {
                  $allIncidents[$date->toDateString()] = [];
              }
          }
  
          // Sort the array so it takes into account the added days
          $allIncidents = $allIncidents->sortBy(function ($value, $key) {
              return strtotime($key);
          }, SORT_REGULAR, false);
  
          return $allIncidents;
      }
code_tokens: protected function getIncidents ( ) { $ allIncidents = Incident :: whereBetween ( 'occurred_at' , [ $ this -> startDate -> copy ( ) -> subDays ( 30 ) -> format ( 'Y-m-d' ) . ' 00:00:00' , $ this -> startDate -> format ( 'Y-m-d' ) . ' 23:59:59' , ] ) -> orderBy ( 'occurred_at' , 'desc' ) -> get ( ) -> groupBy ( function ( Incident $ incident ) { return ( new Date ( $ incident -> occurred_at ) ) -> setTimezone ( $ this -> dateTimeZone ) -> toDateString ( ) ; } ) ; // Add in days that have no incidents foreach ( range ( 0 , 30 ) as $ i ) { $ date = ( new Date ( $ this -> startDate ) ) -> setTimezone ( $ this -> dateTimeZone ) -> subDays ( $ i ) ; if ( ! isset ( $ allIncidents [ $ date -> toDateString ( ) ] ) ) { $ allIncidents [ $ date -> toDateString ( ) ] = [ ] ; } } // Sort the array so it takes into account the added days $ allIncidents = $ allIncidents -> sortBy ( function ( $ value , $ key ) { return strtotime ( $ key ) ; } , SORT_REGULAR , false ) ; return $ allIncidents ; }
docstring: Fetches all of the incidents over the last 30 days.
  
  @return \Illuminate\Support\Collection
docstring_tokens: Fetches all of the incidents over the last 30 days .