So i'm populating my database from a CRM and i'm trying to use the provided id for each item as my primary key (I feel like this will make things less complicated, but if this is bad practice please let me know). The problem is that when the table already has some data and i rerun the function, i get this error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '25930688' for key 'PRIMARY'
Correct me if I'm wrong, but i would've expected Eloquent to check the row exists before trying to insert it. I've tried save, create, firstOrNew, firstOrCreate. They all return the same error. I've searched far and wide but I'm quite new to this so I'm not sure I'm searching for the right terms.
$listing = Property::create([
'id' => $property['@attributes']['id'],
'house_flat_number' => $property['address']['name'],
'street_address_1' => $property['address']['street'],
'street_address_2' => $property['address']['town'],
'postcode' => $property['address']['postcode']