How to create unique relationship using NeoEloquent

247 Views Asked by At

I have just started using Laravel. I have not used Laravel Eloquent before. So I am directly using it on graph database using NeoEloquent. I know I can create relationship using hasMany() and attach() methods. But I want to create relationship only once. Has anybody used NeoEloquent for creating Unique Relationship.

1

There are 1 best solutions below

0
On BEST ANSWER

You may use the hasOne()relationship instead of hasMany() which will ensure that only one relationship of the specified type exists for the model.