I've got this code:
$model->relation->updateOrCreate(['id' => $request->id], $dataArray);
and I recieve the following error:
Call to a member function updateOrCreate() on null
It seems I can't have id be null which can happen in my case, I may send null.
I expected updateOrCreate() to be able to handle this case. If id is null then create new record otherwise just update.
How can I update or create relationship that may not exist without this error getting in the way?