I am trying to update or insert a row (if item not exists ) into the table using findOrCreate
method
Here is my code
Pickupaddress::firstOrCreate(
[
'art_id'=>$artId
],
[
'address_line1' => $request->addressLine1,
'address_line2' => $request->addressLine2,
'country' => $request->country,
'postal_code' => $request->postalCode,
'mobile_number' => $request->mobileNumber,
'region' => $request->region,
'art_id' => Auth::id()
]
);
But only the time stamp fields are updated all other columns are filled with NULL
Edit
Updated strict
value to false
in config\\database.php
but it doesn't woked
Have you set your fields as fillable
in your Pickupaddress
model?
Based on your post it would be something like:
protected $fillable = [
'address_line1',
'address_line2',
'country',
'postal_code',
'mobile_number',
'region',
'art_id'
];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.