Skip to content

Commit

Permalink
System: replace native with carbon
Browse files Browse the repository at this point in the history
  • Loading branch information
esyede committed Aug 18, 2024
1 parent 52dc4c7 commit a1c1e20
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion system/console/commands/make.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
defined('DS') or exit('No direct access.');

use System\Str;
use System\Carbon;
use System\Storage;
use System\Package;

Expand Down Expand Up @@ -222,7 +223,7 @@ public function migration(array $arguments = [])
throw new \Exception(sprintf('Targetted package is not installed: %s', $package));
}

$prefix = date('Y_m_d_His');
$prefix = Carbon::now()->format('Y_m_d_His');
$path = Package::path($package) . 'migrations' . DS;

if (!is_dir($path)) {
Expand Down
3 changes: 2 additions & 1 deletion system/database/facile/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use System\Arr;
use System\Str;
use System\Event;
use System\Carbon;
use System\Validator;

abstract class Model
Expand Down Expand Up @@ -443,7 +444,7 @@ public function delete()
*/
public function timestamp()
{
$this->updated_at = date('Y-m-d H:i:s');
$this->updated_at = Carbon::now()->format('Y-m-d H:i:s');

if (!$this->exists) {
$this->created_at = $this->updated_at;
Expand Down
3 changes: 2 additions & 1 deletion system/database/facile/relationships/belongstomany.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

defined('DS') or exit('No direct access.');

use System\Carbon;
use System\Database\Facile\Model;
use System\Database\Facile\Pivot;

Expand Down Expand Up @@ -189,7 +190,7 @@ protected function join_record($id)
protected function insert_joining(array $attributes)
{
if (Pivot::$timestamps) {
$attributes['created_at'] = date('Y-m-d H:i:s');
$attributes['created_at'] = Carbon::now()->format('Y-m-d H:i:s');
$attributes['updated_at'] = $attributes['created_at'];
}

Expand Down
3 changes: 2 additions & 1 deletion system/database/facile/relationships/hasoneormany.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

defined('DS') or exit('No direct access.');

use System\Carbon;
use System\Database\Facile\Model;

class HasOneOrMany extends Relationship
Expand Down Expand Up @@ -37,7 +38,7 @@ public function insert($attributes)
public function update(array $attributes)
{
if ($this->model->timestamps()) {
$attributes['updated_at'] = date('Y-m-d H:i:s');
$attributes['updated_at'] = Carbon::now()->format('Y-m-d H:i:s');
}

return $this->table->update($attributes);
Expand Down
3 changes: 2 additions & 1 deletion system/email/drivers/driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use System\Arr;
use System\Str;
use System\Email;
use System\Carbon;
use System\Config;
use System\Storage;

Expand Down Expand Up @@ -552,7 +553,7 @@ public function send($validate = null)
$this->headers = [];
$boundary = md5(Str::random(16));
$this->boundaries = ['B1_' . $boundary, 'B2_' . $boundary, 'B3_' . $boundary];
$this->set_header('Date', date('r'));
$this->set_header('Date', Carbon::now()->format('r'));

$path = (false === $this->config['return_path'])
? $this->config['from']['email']
Expand Down
7 changes: 4 additions & 3 deletions system/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Log
*/
public static function channel($name = null)
{
$name = (is_string($name) && strlen($name)) ? Str::slug($name) : date('Y-m-d');
$name = (is_string($name) && strlen($name)) ? Str::slug($name) : Carbon::now()->format('Y-m-d');
static::$channel = Str::replace_last('.log', '', Str::replace_last('.php', '', $name));
}

Expand Down Expand Up @@ -79,7 +79,7 @@ protected static function write($type, $message, $data = null)
}

$channel = static::$channel;
$channel = (is_string($channel) && strlen($channel)) ? Str::slug($channel) : date('Y-m-d');
$channel = (is_string($channel) && strlen($channel)) ? Str::slug($channel) : Carbon::now()->format('Y-m-d');
$path = path('storage') . 'logs' . DS . $channel . '.log.php';
$message = static::format($type, $message);

Expand All @@ -97,6 +97,7 @@ protected static function write($type, $message, $data = null)
protected static function format($type, $message)
{
$env = Foundation\Oops\Debugger::$productionMode ? 'production' : 'local';
return sprintf('[%s] %s.%s: %s' . PHP_EOL, date('Y-m-d H:i:s'), $env, strtoupper((string) $type), $message);
$date = Carbon::now()->format('Y-m-d H:i:s');
return sprintf('[%s] %s.%s: %s' . PHP_EOL, $date, $env, strtoupper((string) $type), $message);
}
}

0 comments on commit a1c1e20

Please sign in to comment.