Vinelab / NeoEloquent

The Neo4j OGM for Laravel
MIT License
636 stars 200 forks source link

firstOrCreate does not save values. Returns edge on create and model on first. #249

Closed oberoivarun closed 6 years ago

oberoivarun commented 7 years ago

Laravel 5.3 NeoEloduent 1.4.*

Recreate problem

$facility->customers()->firstOrCreate(['customer_id' => '170933920'],['customer_name' => 'John Doe']);

If such a node does not exist, then NeoEloquent will create it with only the customer_id property, it will ignore the customer_name. And then it will return an edgeOut instance.

If such a node does exist, then it will return the node.

Behaviour expected:

Return an edge or return the model both times. Also, if created... save the values array along with the attributes array.

Mulkave commented 6 years ago

The call to firstOrCreate should be as follows:

firstOrCreate(['customer_id' => '170933920', 'customer_name' => 'John Doe'])