public function withComponent($components, $callback = null)
    {
        return $this->filter(function ($object) use ($components, $callback) {

            $hasComponent = false;

            foreach ((array) $components as $componentName) {

                if (!$callback && $object->hasComponent($componentName)) {
                    $hasComponent = true;
                }

                if ($callback && ($component = $object->getComponent($componentName))) {
                    $hasComponent = call_user_func($callback, $component) ?: $hasComponent;
                }
            }

            return $hasComponent;
        });
    }
public function withComponent($components, $callback = null)
    {
        return $this->filter(function ($object) use ($components, $callback) {

            $hasComponent = false;

            foreach ((array) $components as $componentName) {

                if (!$callback && $object->hasComponent($componentName)) {
                    $hasComponent = true;
                }

                if ($callback && ($component = $object->getComponent($componentName))) {
                    $hasComponent = call_user_func($callback, $component) ?: $hasComponent;
                }
            }

            return $hasComponent;
        });
    }
public function withComponent ( $ components , $ callback = null ) { return $ this -> filter ( function ( $ object ) use ( $ components , $ callback ) { $ hasComponent = false ; foreach ( ( array ) $ components as $ componentName ) { if ( ! $ callback && $ object -> hasComponent ( $ componentName ) ) { $ hasComponent = true ; } if ( $ callback && ( $ component = $ object -> getComponent ( $ componentName ) ) ) { $ hasComponent = call_user_func ( $ callback , $ component ) ? : $ hasComponent ; } } return $ hasComponent ; } ) ; }
Returns objects that use the supplied component.
@param  string|array $components
@param null|callback $callback
@return static
Returns objects that use the supplied component .