public function hasAllWidgets($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')->count() === count($widgets)
                && $this->widgets->pluck('id')->diff($widgets)->isEmpty();
        }

        // Array of widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_int($widgets[0])) {
            return $this->widgets->pluck('id')->count() === count($widgets)
                && $this->widgets->pluck('id')->diff($widgets)->isEmpty();
        }

        // Collection of widget models
        if ($widgets instanceof Collection) {
            return $this->widgets->count() === $widgets->count() && $this->widgets->diff($widgets)->isEmpty();
        }

        return false;
    }
public function hasAllWidgets($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')->count() === count($widgets)
                && $this->widgets->pluck('id')->diff($widgets)->isEmpty();
        }

        // Array of widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_int($widgets[0])) {
            return $this->widgets->pluck('id')->count() === count($widgets)
                && $this->widgets->pluck('id')->diff($widgets)->isEmpty();
        }

        // Collection of widget models
        if ($widgets instanceof Collection) {
            return $this->widgets->count() === $widgets->count() && $this->widgets->diff($widgets)->isEmpty();
        }

        return false;
    }
public function hasAllWidgets ( $ 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' ) -> count ( ) === count ( $ widgets ) && $ this -> widgets -> pluck ( 'id' ) -> diff ( $ widgets ) -> isEmpty ( ) ; } // Array of widget ids if ( is_array ( $ widgets ) && isset ( $ widgets [ 0 ] ) && is_int ( $ widgets [ 0 ] ) ) { return $ this -> widgets -> pluck ( 'id' ) -> count ( ) === count ( $ widgets ) && $ this -> widgets -> pluck ( 'id' ) -> diff ( $ widgets ) -> isEmpty ( ) ; } // Collection of widget models if ( $ widgets instanceof Collection ) { return $ this -> widgets -> count ( ) === $ widgets -> count ( ) && $ this -> widgets -> diff ( $ widgets ) -> isEmpty ( ) ; } return false ; }
Determine if the model has all of the given widgets.

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

@return bool
Determine if the model has all of the given widgets .