/** * @param array $attributes * @return mixed */ public function findWithAttributes(array $attributes) { $verification = parent::findWithAttributes($attributes); if (is_null($verification)) { $verification = $this->createIfNotExists($attributes); } return $verification; }
/** * @param array $attributes * @return Model */ public function createWithAttributes(array $attributes) { $vars = array_merge(['code' => $this->generateToken(), 'expires_at' => Carbon::now()->addMinutes(10)->toDateTimeString()], $attributes); return parent::createWithAttributes($vars); }