Esempio n. 1
0
 public function register()
 {
     \Model::extend(function ($model) {
         $model->bindEvent('model.beforeSetAttribute', function ($key, $value) use($model) {
             Argon::$jalali = false;
         });
         $model->bindEvent('model.setAttribute', function ($key, $value) use($model) {
             Argon::$jalali = true;
         });
     });
     $this->fixValidations();
     $this->fixJs();
     $this->addAssets();
     $this->replaceClasses();
 }
Esempio n. 2
0
 /**
  * Converts mixed inputs to a Carbon object.
  *
  * @return Argon
  */
 public static function makeCarbon($value, $throwException = true)
 {
     if ($value instanceof Argon) {
         // Do nothing
     } elseif ($value instanceof PhpDateTime) {
         $value = Argon::instance($value);
     } elseif (is_numeric($value)) {
         $value = Argon::createFromTimestamp($value);
     } elseif (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) {
         $value = Argon::createFromFormat('Y-m-d', $value)->startOfDay();
     } else {
         try {
             $value = Argon::parse($value);
         } catch (Exception $ex) {
         }
     }
     if (!$value instanceof Argon && $throwException) {
         throw new InvalidArgumentException('Invalid date value supplied to DateTime helper.');
     }
     return $value;
 }