nova-order-field icon indicating copy to clipboard operation
nova-order-field copied to clipboard

Relations conflict on the same model

Open maxon755 opened this issue 4 years ago • 0 comments

Hi, guys! Your package is awesome. But I've got an error. I have a model that should be orderable within BelongsTo and BelongsToMany relations at the same time. So, my Nova resource uses Orderable, HasOrderablePivot. When I am going to page with BelongsTo relation I am getting an error:

Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::getPivotClass()

The fix is very easy, just to check the type of $realtion in HasOrderablePivot::orderedManyPivotModel()

        if(
            !$relationship ||
            !$relationship instanceof BelongsToMany ||
            !$relationship->getPivotClass()
        ) {
            return;
        }

It works fine for me. Waiting for your answer :smiley:

maxon755 avatar Jul 04 '20 06:07 maxon755