src/Searsaw/Drawbridge/models/BridgeUser.php
public function addRoleByName($role_name)
    {
        $role = static::$app['db']->connection()
            ->table('roles')->where('name', '=', $role_name)->first();

        if (! $role)
            throw new \RuntimeException('No role with that name found.');

        if (is_array($role))
            return $this->addRoleById($role['id']);
        elseif (is_object($role))
            return $this->addRoleById($role->id);
        else
            throw new \UnexpectedValueException('Value returned not array or instance of BridgeRole.');
    }
public function addRoleByName($role_name)
    {
        $role = static::$app['db']->connection()
            ->table('roles')->where('name', '=', $role_name)->first();

        if (! $role)
            throw new \RuntimeException('No role with that name found.');

        if (is_array($role))
            return $this->addRoleById($role['id']);
        elseif (is_object($role))
            return $this->addRoleById($role->id);
        else
            throw new \UnexpectedValueException('Value returned not array or instance of BridgeRole.');
    }
public function addRoleByName ( $ role_name ) { $ role = static :: $ app [ 'db' ] -> connection ( ) -> table ( 'roles' ) -> where ( 'name' , '=' , $ role_name ) -> first ( ) ; if ( ! $ role ) throw new \ RuntimeException ( 'No role with that name found.' ) ; if ( is_array ( $ role ) ) return $ this -> addRoleById ( $ role [ 'id' ] ) ; elseif ( is_object ( $ role ) ) return $ this -> addRoleById ( $ role -> id ) ; else throw new \ UnexpectedValueException ( 'Value returned not array or instance of BridgeRole.' ) ; }
Add a single role to the user by name

@param $role_name string The name of the role to add

@throws \RuntimeException
@throws \UnexpectedValueException

@return \Searsaw\Drawbridge\Models\BridgeRole
Add a single role to the user by name