/** * @param Account $account * @param string $type * * @return Account */ public function updateAccountType(Account $account, string $type) : Account { $type = AccountType::whereType($type)->first(); if (!is_null($type)) { $account->accountType()->associate($type); $account->save(); } return $this->find($account->id); }