public function hasWidget($widgets): bool
    {
        // Single Widget id
        if (is_string($widgets)) {
            return $this->widgets->contains('id', $widgets);
        }

        // Single Widget id
        if (is_int($widgets)) {
            return $this->widgets->contains('id', $widgets);
        }

        // Single Widget model
        if ($widgets instanceof WidgetModelContract) {
            return $this->widgets->contains('id', $widgets->id);
        }

        // Array of Widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_string($widgets[0])) {
            return ! $this->widgets->pluck('id')->intersect($widgets)->isEmpty();
        }

        // Array of Widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_int($widgets[0])) {
            return ! $this->widgets->pluck('id')->intersect($widgets)->isEmpty();
        }

        // Collection of Widget models
        if ($widgets instanceof Collection) {
            return ! $widgets->intersect($this->widgets->pluck('id'))->isEmpty();
        }

        return false;
    }
public function hasWidget($widgets): bool
    {
        // Single Widget id
        if (is_string($widgets)) {
            return $this->widgets->contains('id', $widgets);
        }

        // Single Widget id
        if (is_int($widgets)) {
            return $this->widgets->contains('id', $widgets);
        }

        // Single Widget model
        if ($widgets instanceof WidgetModelContract) {
            return $this->widgets->contains('id', $widgets->id);
        }

        // Array of Widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_string($widgets[0])) {
            return ! $this->widgets->pluck('id')->intersect($widgets)->isEmpty();
        }

        // Array of Widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_int($widgets[0])) {
            return ! $this->widgets->pluck('id')->intersect($widgets)->isEmpty();
        }

        // Collection of Widget models
        if ($widgets instanceof Collection) {
            return ! $widgets->intersect($this->widgets->pluck('id'))->isEmpty();
        }

        return false;
    }
public function hasWidget ( $ widgets ) : bool { // Single Widget id if ( is_string ( $ widgets ) ) { return $ this -> widgets -> contains ( 'id' , $ widgets ) ; } // Single Widget id if ( is_int ( $ widgets ) ) { return $ this -> widgets -> contains ( 'id' , $ widgets ) ; } // Single Widget model if ( $ widgets instanceof WidgetModelContract ) { return $ this -> widgets -> contains ( 'id' , $ widgets -> id ) ; } // Array of Widget ids if ( is_array ( $ widgets ) && isset ( $ widgets [ 0 ] ) && is_string ( $ widgets [ 0 ] ) ) { return ! $ this -> widgets -> pluck ( 'id' ) -> intersect ( $ widgets ) -> isEmpty ( ) ; } // Array of Widget ids if ( is_array ( $ widgets ) && isset ( $ widgets [ 0 ] ) && is_int ( $ widgets [ 0 ] ) ) { return ! $ this -> widgets -> pluck ( 'id' ) -> intersect ( $ widgets ) -> isEmpty ( ) ; } // Collection of Widget models if ( $ widgets instanceof Collection ) { return ! $ widgets -> intersect ( $ this -> widgets -> pluck ( 'id' ) ) -> isEmpty ( ) ; } return false ; }
Determine if the model has any the given widgets.

@param int|string|array|\ArrayAccess|WidgetModelContract $widgets

@return bool
Determine if the model has any the given widgets .