I got error when my Model has no updated_at, Then update data or deleted data use SoftDeletes.
I use this code for set updated_at.
public function setUpdatedAt($value)
{
return $this;
}
App\Model::destroy(569) always got error.
Illuminate\Database\QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: update `models` set `delete
d_at` = 2017-09-19 18:04:19, `updated_at` = 2017-09-19 18:04:19 where `id` = 569)'
But with Model::create($data); it's fine.
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Model extends Model
{
use SoftDeletes;
protected $fillable = [
'data'
];
/**
* Set the value of the "updated at" attribute.
*
* @param mixed $value
* @return $this
*/
public function setUpdatedAt($value)
{
return $this;
}
}
Similar to #20901
@Dylan-DPC Oh, Got it. Thanks
const UPDATED_AT = null;
/**
* Set the value of the "updated at" attribute.
*
* @param mixed $value
* @return $this
*/
public function setUpdatedAt($value)
{
return $this;
}
I'm not sure 100%, but setUpdatedAt method is not required when UPDATED_AT = null constant is added.
@a-komarev Not with 5.5 #20948
update your model with this:
public $timestamps = false;
public $timestamps = false; worked for me! thanks
WORKED for me !!!!!
public $timestamps = false;
thanks @Nitish27
Most helpful comment
update your model with this:
public $timestamps = false;