Exemplo n.º 1
0
 public function actionCheck()
 {
     $dt = new \DateTime();
     echo 'Current date/time: ' . $dt->format('Y-m-d H:i:s');
     echo '<br/>';
     echo 'Current timezone: ' . $dt->getTimezone()->getName();
     echo '<br/>';
 }
Exemplo n.º 2
0
 public function scopeMonthly($query)
 {
     $dt = new \DateTime();
     $month = intval($dt->format('n'));
     $year = intval($dt->format('Y'));
     $target_year_month = null;
     if ($month == '1') {
         $target_year_month = $year - 1 . '12';
     } else {
         $target_year_month = $year . ($month - 1 < 10 ? "0" . ($month - 1) : $month - 1);
     }
     $query->Join('projects', function ($join) {
         $join->on('claims.project_id', '=', 'projects.id')->where('projects.reports_type', '=', \DB::raw('monthly'));
     })->whereRaw('EXTRACT(YEAR_MONTH FROM claims.created_at)=' . $target_year_month);
     return $query;
 }