UpdateOrCreate with model instance

I am using PHP 7.1.33 and Laravel Framework 5.8.36.

I am getting receiving data from a database row-by-row and I am creating a model using updateOrCreate() like the following:

foreach ($arr as $v) {

$product = new Product();
$product->name = $v['name'];
$product->url = $v['url'];
$product->price = $v['price'];

// save
$matchThese = ['name' => $name, 'url' => $url];
$product->updateOrCreate($matchThese);
}

However, nothing gets created.

Any suggestions what I am doing wrong?

I appreciate your replies!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36BoK89
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time