diff --git a/core/Application.php b/core/Application.php index 21c3df7e..cf54afe0 100644 --- a/core/Application.php +++ b/core/Application.php @@ -28,9 +28,9 @@ public function execute() { $response = new Response(); - try { Router::dispatch(new Request(), $response); } - - catch (Exception $e) { + try { + Router::dispatch(new Request(), $response); + } catch (Exception $e) { if (config('errors.log')) save_log('Exception: ' . $e); if (config('errors.display')) die($e); diff --git a/core/Support/Mailer/Mailer.php b/core/Support/Mailer/Mailer.php index ed880870..f4fd100c 100644 --- a/core/Support/Mailer/Mailer.php +++ b/core/Support/Mailer/Mailer.php @@ -38,8 +38,7 @@ public function __construct() } if (config('mailer.smtp.secure')) { - $this->mailer->SMTPSecure = config('mailer.smtp.tls') - ? PHPMailer::ENCRYPTION_STARTTLS + $this->mailer->SMTPSecure = config('mailer.smtp.tls') ? PHPMailer::ENCRYPTION_STARTTLS : PHPMailer::ENCRYPTION_SMTPS; } else { $this->mailer->SMTPAutoTLS = false; diff --git a/core/Support/Metrics.php b/core/Support/Metrics.php index 988d5e5d..e9a20955 100644 --- a/core/Support/Metrics.php +++ b/core/Support/Metrics.php @@ -12,7 +12,7 @@ use Core\Database\QueryBuilder; /** - * Metrics generator + * Metrics and trends generator */ class Metrics { @@ -89,8 +89,7 @@ public function getTrends(string $column, string $type, string $period, int $int case self::DAY: $qb->select($type . '(' . $column . ') AS data', $this->getPeriod(self::DAY)); - $interval > 0 - ? $qb->where('date(created_at)', '>=', Carbon::now()->subDays($interval)->toDateString()) + $interval > 0 ? $qb->where('date(created_at)', '>=', Carbon::now()->subDays($interval)->toDateString()) : $qb->whereColumn($this->formatPeriod(self::YEAR))->like($year) ->andColumn($this->formatPeriod(self::MONTH))->like($month) ->andColumn($this->formatPeriod(self::WEEK))->like($week); @@ -109,8 +108,7 @@ public function getTrends(string $column, string $type, string $period, int $int case self::WEEK: $qb->select($type . '(' . $column . ') AS data', $this->getPeriod(self::WEEK)); - $interval > 0 - ? $qb->where('date(created_at)', '>', Carbon::now()->subWeeks($interval)->toDateString()) + $interval > 0 ? $qb->where('date(created_at)', '>', Carbon::now()->subWeeks($interval)->toDateString()) : $qb->whereColumn($this->formatPeriod(self::YEAR))->like($year) ->andColumn($this->formatPeriod(self::MONTH))->like($month); @@ -128,8 +126,7 @@ public function getTrends(string $column, string $type, string $period, int $int case self::MONTH: $qb->select($type . '(' . $column . ') AS data', $this->getPeriod(self::MONTH)); - $interval > 0 - ? $qb->where($this->formatPeriod(self::MONTH), '>', Carbon::now()->subMonths($interval)->month) + $interval > 0 ? $qb->where($this->formatPeriod(self::MONTH), '>', Carbon::now()->subMonths($interval)->month) : $qb->where($this->formatPeriod(self::YEAR), $year); $data = $qb->subQuery(function ($q) use ($query) { @@ -186,8 +183,7 @@ public function get(string $column, string $type, string $period, int $interval case self::DAY: $qb->select($type . '(' . $column . ') AS data'); - $interval > 0 - ? $qb->where('date(created_at)', '>=', Carbon::now()->subDays($interval)->toDateString()) + $interval > 0 ? $qb->where('date(created_at)', '>=', Carbon::now()->subDays($interval)->toDateString()) : $qb->whereColumn($this->formatPeriod(self::YEAR))->like($year) ->andColumn($this->formatPeriod(self::MONTH))->like($month) ->andColumn($this->formatPeriod(self::WEEK))->like($week); @@ -202,8 +198,7 @@ public function get(string $column, string $type, string $period, int $interval case self::WEEK: $qb->select($type . '(' . $column . ') AS data'); - $interval > 0 - ? $qb->where('date(created_at)', '>', Carbon::now()->subWeeks($interval)->toDateString()) + $interval > 0 ? $qb->where('date(created_at)', '>', Carbon::now()->subWeeks($interval)->toDateString()) : $qb->whereColumn($this->formatPeriod(self::YEAR))->like($year) ->andColumn($this->formatPeriod(self::MONTH))->like($month); @@ -217,8 +212,7 @@ public function get(string $column, string $type, string $period, int $interval case self::MONTH: $qb->select($type . '(' . $column . ') AS data'); - $interval > 0 - ? $qb->where($this->formatPeriod(self::MONTH), '>', Carbon::now()->subMonths($interval)->month) + $interval > 0 ? $qb->where($this->formatPeriod(self::MONTH), '>', Carbon::now()->subMonths($interval)->month) : $qb->where($this->formatPeriod(self::YEAR), $year); return $qb->subQuery(function ($q) use ($query) { @@ -255,23 +249,19 @@ private function formatPeriod(string $period) { switch ($period) { case self::DAY: - return config('database.driver') === 'mysql' - ? 'weekday(created_at)' + return config('database.driver') === 'mysql' ? 'weekday(created_at)' : "strftime('%w', created_at)"; case self::WEEK: - return config('database.driver') === 'mysql' - ? 'week(created_at)' + return config('database.driver') === 'mysql' ? 'week(created_at)' : "strftime('%W', created_at)"; case self::MONTH: - return config('database.driver') === 'mysql' - ? 'month(created_at)' + return config('database.driver') === 'mysql' ? 'month(created_at)' : "strftime('%m', created_at)"; case self::YEAR: - return config('database.driver') === 'mysql' - ? 'year(created_at)' + return config('database.driver') === 'mysql' ? 'year(created_at)' : "strftime('%Y', created_at)"; default: return ''; @@ -286,8 +276,7 @@ private function formatDate(array $data, string $period) if ($period === self::MONTH) { $data->$period = self::MONTHS[intval($data->$period)]; } else if ($period === self::DAY || $period === self::TODAY) { - $data->$period = config('database.driver') === 'mysql' - ? self::DAYS[intval($data->$period) + 1] + $data->$period = config('database.driver') === 'mysql' ? self::DAYS[intval($data->$period) + 1] : self::DAYS[intval($data->$period)]; } else if ($period === self::WEEK) { $data->$period = __('week') . ' ' . $data->$period;