/**
  * Check to see if user is associated with account
  *
  * @param $user
  *
  * @return bool
  */
 protected function accountUserExists($user)
 {
     $accountUser = $this->accountRepository->getByUser($user);
     if ($accountUser) {
         return true;
     }
     return false;
 }
 /**
  * Creates a new account record, assigns
  *
  * @param $command
  */
 public function handle($command)
 {
     // Create account
     $account = Account::create([]);
     $this->accountRepository->save($account);
     $language = $this->languageRepository->getByCode($command->defaultLanguageCode);
     $account->addLanguage($language);
     $account->addTranslation($language->code, 'name', $command->name);
     $account->addDomain($command->domain);
     $this->dispatcher->dispatch($account->releaseEvents());
 }
 /**
  * Handle the command.
  *
  * @param $command
  */
 public function handle($command)
 {
     // Create account
     $account = Account::install();
     // Add new user record and assign to account
     $user = User::install($command->email, $command->password);
     $this->users->save($user);
     $account->setOwner($user);
     $this->accountRepository->save($account);
     // Set the current account for the request. This is necessary for some other tasks
     CurrentAccount::set($account);
     $language = $this->addLanguage($account, $command->language);
     $account->addUser($user);
     $account->addTranslation($language->code, 'name', $command->name);
     $account->addDomain($command->host);
     // Dispatch all events associated with various objects
     $this->dispatcher->dispatch($account->releaseEvents());
     $this->dispatcher->dispatch($user->releaseEvents());
 }
Esempio n. 4
0
 /**
  * Determines the account that is being used for the current request.
  *
  * @return Account
  */
 public function determine($domain)
 {
     return $this->accountRepository->requireByDomain($domain);
 }
Esempio n. 5
0
 protected function seedAccount()
 {
     $account = Account::install();
     $this->accounts->save($account);
     $this->translationService->sync($account, ['name' => ['en_GB' => 'Tectonic']]);
 }
Esempio n. 6
0
 /**
  * Retrieve a single account based on the slug provided.
  *
  * @Get("accounts/{slug}", middleware={"shift.account", "shift.auth"}, as="accounts.show")
  *
  * @param $slug
  */
 public function getShow($slug)
 {
     $account = Translator::translate($this->accountRepository->requireBySlug($slug));
     return $this->respond('shift::accounts.edit', compact('account'));
 }
Esempio n. 7
0
 /**
  * Transfers an account's ownership to another user.
  *
  * @param Account $account
  * @param UserInterface $user
  * @returns Account
  */
 public function transferOwnership(Account $account, User $user)
 {
     $account->setOwner($user);
     $this->accountRepository->save($account);
     $this->dispatcher->dispatch($account->releaseEvents());
 }