Skip to content

Commit

Permalink
feat: move views folder to root project
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseekn committed Dec 24, 2021
1 parent 97c0cd2 commit 8949396
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
6 changes: 3 additions & 3 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions core/Support/Mailer/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 12 additions & 23 deletions core/Support/Metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Core\Database\QueryBuilder;

/**
* Metrics generator
* Metrics and trends generator
*/
class Metrics
{
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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) {
Expand Down Expand Up @@ -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 '';
Expand All @@ -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;
Expand Down

0 comments on commit 8949396

Please sign in to comment.