mercredi 10 août 2022

created_at and updated_at columns not updated by updateorcreate - Laravel Eloquent

Hey All I am new to Laravel. I have a table called dsp_account_fee. enter image description here enter image description here

This is what I have in my Model.

{
    use AdvancedInserts;

    protected $table = "dsp_account_fee";
    protected $primaryKey = 'dsp_account_id';
    protected $secondaryKey = 'screen_type';


    public $timestamps = false;

    protected function setKeysForSaveQuery(Builder $query)
    {
        parent::setKeysForSaveQuery($query);
        $query->where($this->secondaryKey, '=', $this->{$this->secondaryKey});
        return $query;
    }

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

}

When I create or update record I use the updateorcreate method like this:

$res1 = 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']]
                );

The problem is that the created_at and the updated_at not filled automatically and stay null. what I am missing?



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

Aucun commentaire:

Enregistrer un commentaire