【发布时间】:2019-05-11 23:23:29
【问题描述】:
我在控制器中使用最新的 Laravel 和这段代码:
function changeProperty(Request $request){
if(Car::find('id', 34)->save(array('expired' => true))){
return [
'success' => true,
'check' => Car::find(34)
];
}
return [
'success' => false
];
}
我收到success => true,但是当我签入 PHPMyAdmin 时,该值没有保存。
在Property::find(34) 中,我看到选择了 Car,但也没有更新值 expired,默认为 0。
这是Car 模型的一部分:
protected $fillable = [
'expired'
];
这是汽车表的迁移:
public function up()
{
Schema::create('cars', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->boolean('expired')->default(false);
$table->timestamps();
});
}
【问题讨论】: