public function assignGroup($group)
    {
        if (Group::count() === 0) {
            throw new \Exception('No groups have been created.');
        }

        return $this->groups()->save(
            Group::whereName($group)->firstOrFail()
        );
    }
public function assignGroup($group)
    {
        if (Group::count() === 0) {
            throw new \Exception('No groups have been created.');
        }

        return $this->groups()->save(
            Group::whereName($group)->firstOrFail()
        );
    }
public function assignGroup ( $ group ) { if ( Group :: count ( ) === 0 ) { throw new \ Exception ( 'No groups have been created.' ) ; } return $ this -> groups ( ) -> save ( Group :: whereName ( $ group ) -> firstOrFail ( ) ) ; }
Assign the given group to the user.

@param  string $group

@return mixed
@throws \Exception
Assign the given group to the user .