How To Remove `created_at`, `updated_at` From Insert Query (when Create A Model Record)?

- 1 answer

There is a backend page with a form with two fields (fake_uid, auth_key). When I create new record an error occurs and tells the following:

Column not found: 1054 Unknown column 'fake_uid' in 'field list' (SQL: insert into 'fakes_list' ('fake_uid', 'auth_key', 'updated_at', 'created_at') values (45345, 345345, 2019-02-03 09:57:11, 2019-02-03 09:57:11))...

The table fakes_list doesn't have updated_at and created_at columns. How can I remove them from the query? And how to change fake_uid to name of some column? Because there is no such column, indeed (as the error says).

I tried to add $purgable variable to my model:

use \October\Rain\Database\Traits\Purgeable;
protected $purgeable = ['created_at', 'updated_at'];

Not working. But if I add, for example, fake_uid - it will be removed from the query. Hm??



By default, a model will expect created_at and updated_at columns to exist on your tables. If you do not wish to have these columns managed automatically, set the $timestamps property on your model to false:

class Post extends Model
     * Indicates if the model should be timestamped.
     * @var bool
    public $timestamps = false;

To remove the fake_uid column, edit the fields.yaml file associated to the backend form that you are using and remove / change the name of that field.