staudenmeir / eloquent-has-many-deep

Laravel Eloquent HasManyThrough relationships with unlimited levels
MIT License
2.67k stars 157 forks source link

Call to undefined method Staudenmeir\EloquentHasManyDeep\HasManyDeep::save() #59

Closed shanerbaner82 closed 4 years ago

shanerbaner82 commented 4 years ago

Hello again, I am using your package with Nova and running into this issue when creating a new Client.

Call to undefined method Staudenmeir\EloquentHasManyDeep\HasManyDeep::save()

Brokers have many leaders, leaders have many agents, agents many to many clients.

staudenmeir commented 4 years ago

This is a fundamental issue: Due to the intermediate tables, you can't use HasManyDeep/HasManyThrough relationships to create/save models as you can with HasMany relationships.

When you create a new client for an existing broker, the relationship could only connect them, if it would know the leaders and agents the client and broker are connected by. In your case, the relationship would also have to create a record in the agent_client pivot table.

dan-lutd commented 2 years ago

@shanerbaner82 Did you get Staudenmeir\EloquentHasManyDeep to work with Nova? Not the save but using hasManyDeep or hasManyDeepFromRelations with queries?