/** * @throws \App\Exceptions\EntityNotFoundException * @return mixed */ public function entity() { if (empty($this->entity)) { throw new EntityNotFoundException(); } return $this->entity->load($this->with); }
public static function observers() { parent::observers(); self::creating(function (Organization $organization) { $settings = new OrganizationSettings(); $settings->save(); $organization->settings()->associate($settings); }); self::created(function (Organization $organization) { $successful = false; while (!$successful) { try { $organization->generateVerificationCode(); $successful = $organization->save(); } catch (QueryException $e) { $successful = false; } } }); }