user()->isAdmin(); } public function rules() { $this->sanitize(); $rules = []; $rules['first_name'] = 'required|string|max:100'; $rules['last_name'] = 'required|string|max:100'; if (config('ninja.db.multi_db_enabled')) { $rules['email'] = new ValidUserForCompany(); } return $rules; } public function sanitize() { $input = $this->all(); if(isset($input['company_user'])) { if(!isset($input['company_user']['is_admin'])) $input['company_user']['is_admin'] = false; if(!isset($input['company_user']['permissions'])) $input['company_user']['permissions'] = ''; if(!isset($input['company_user']['settings'])) $input['company_user']['settings'] = json_encode(DefaultSettings::userSettings()); } else{ $input['company_user'] = [ 'settings' => json_encode(DefaultSettings::userSettings()), 'permissions' => '', ]; } $this->replace($input); return $this->all(); } public function fetchUser() :User { $user = MultiDB::hasUser(['email' => $this->input('email')]); if(!$user) $user = UserFactory::create(); return $user; } }