0

I have 1:N relation where parent table LOCATIONS contains fields server_id and location_id and table DEVICES is related to the LOCATIONS throught fields server_id and location_id. How can I establish the HasMany() and BelongsTo() between this two tables?

If I use this it throws me an error: "Array to string conversion".

 public function devices(): HasMany
 {
     return $this->hasMany(Device::class, ['server_id', 'location_id'], ['server_id', 'location_id']);
 }

1 Answer 1

0

As I found out there is no way to do it in pure Laravel but there is a package which solve this issue https://github.com/topclaudy/compoships

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.