mercredi 10 août 2022

UpdateOrCreate not updating data - Laravel Eloquent

I am new to laravel. I have an issue when I am trying to update or create record in DB. I have a table called DspAccountFee with this columns: enter image description here

I want to create record of dsp_account_id + screen_type when the combination not exists, and to update if the combination exists. this is my code: (just tried to update the first row keys of -> dsp_account_id(5187) + screen type (ctv). However nothing changed.

DspAccountFee::updateOrCreate(
                ['dsp_account_id' => $dsp_account_id, 'screen_type' => 'ctv'],
                ['pmp_percent' =>$fields['fee_ctv_pmp_percent'], 'omp_percent' => $fields['fee_ctv_omp_percent']]
                );

When I print the values before the DB operation they exists:

\Log::info("dsp_account:");
\Log::info($dsp_account_id);
\Log::info("ctv pmp percent:");
\Log::info($fields['fee_ctv_pmp_percent']);
\Log::info("ctv omp percent:");
\Log::info($fields['fee_ctv_omp_percent']);
\Log::info("app pmp percent:");

enter image description here

What I am missing why it is not update the db? Nothing in logs and No exception

this is my method in the model

protected $fillable = array(
        'dsp_account_id', 'screen_type'
    );


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire