mardi 9 août 2022

How to Update and Create record in DB - Laravel Eloquent [duplicate]

Hey All I am new to Laravel Eloquent.

I have a table called account id, that I need to write and update data.

when I try to update existing record it is working, However if the record not exists I need to add the record to the DB.

this is my code

AccountID::where('account_id', '=' ,$account_id) -> where('screen_type', '=', "ctv") -> update($update_account_ctv);
    
 AccountID::where('account_id', '=' ,$account_id) -> where('screen_type', '=', "app") -> update($update_account_app);
    
AccountID::where('account_id', '=' ,$account_id) -> where('screen_type', '=', "site") -> update($update_account_site);

How I can resolve this issue that will create a record if the record not exists



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire