嘿,我是 Laravel 的新手。我有一個名為 dsp_account_fee 的表。

這就是我的模型中的內容。
{
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'
);
}
當我創建或更新記錄時,我使用如下 updateorcreate 方法:
$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']]
);
問題是 created_at 和 updated_at 沒有自動填充并保持為空。我錯過了什么?
uj5u.com熱心網友回復:
將其設定為 true 或將其洗掉為 Laravel 默認設定為 true。
public $timestamps = true;
uj5u.com熱心網友回復:
我認為您需要更改$timestamps為true
public $timestamps = true;
uj5u.com熱心網友回復:
從模型中洗掉它
public $timestamps = false;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/504953.html
