I have the following 2 Models: users and emailaccounts and emailaccounts has the user.id as a FK attribute. I use users hasOne emailaccount && emailaccount belongsTo a user.
Now I want to updateOrCreate a new user. Buit for the first Parameter of updateOrCreate, I need a relation value! So how can I do something like this?
$user = \App\Users::has('emailaccounts')->updateOrCreate( ['emailaccounuts.emailadress' => $email, 'users.lastname' => $lastname], ['users.firstname' => $firstname, 'enabled' => "1"] );
So I want to achieve, that I want to search a users which have a emailaccounts entry, and filter them by email adress, if I found it, I want to update the user and relation with the firstname and enabled flag as well. Over two Tables.
Any Ideas will be welcome!
Kind Regards, Marcel