Example #1
0
 /**
  * Ensures the client or user is in the system
  *
  * @return boolean
  */
 public function ensureObject()
 {
     if ($this->type === 'user') {
         $result = User::ensure($this->id);
         if ($result) {
             $context = app('context');
             if ($context->getProviderId()) {
                 $result = User::ensureRole($this->id, ['student'], $context->getProviderId());
             }
             if ($this->isSuperAdmin) {
                 $result = $result && User::ensureRole($this->id, ['super_administrator']);
             }
         }
         return $result;
     } elseif ($this->type === 'client') {
         return Client::ensure($this->id);
     }
     return false;
 }