public static function register(Users $user, string $name): Companies
    {
        $company = new self();
        $company->name = $name;
        $company->users_id = $user->getId();

        if (!$company->save()) {
            throw new Exception(current($company->getMessages()));
        }

        return $company;
    }
public static function register(Users $user, string $name): Companies
    {
        $company = new self();
        $company->name = $name;
        $company->users_id = $user->getId();

        if (!$company->save()) {
            throw new Exception(current($company->getMessages()));
        }

        return $company;
    }
public static function register ( Users $ user , string $ name ) : Companies { $ company = new self ( ) ; $ company -> name = $ name ; $ company -> users_id = $ user -> getId ( ) ; if ( ! $ company -> save ( ) ) { throw new Exception ( current ( $ company -> getMessages ( ) ) ) ; } return $ company ; }
Register a company given a user and name

@param  Users  $user
@param  string $name
@return Companies
Register a company given a user and name