简体   繁体   中英

Eloquent Model adding row without “created_at” and “updated_at” fields

So in my SQL I have table that contains only three fields -- row id, person id and status id, and I want to add new rows using Laravel models, and when I use

$a = new AssignedStatus;
$a->person_id = $person_id;
$a->status_id = $status_id;
$a->save();

I get SQL error telling that columns "created_at" and "updated_at" are not found in this table. Is it somehow possible to get rid of them and just insert row, or is it easier to use DB::table connection?

在AssignedStatus模型中,您需要声明:

public $timestamps = false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM