Is is necessary to always create column created_by in table while inserting data in table using save() method?

Posted 1 year ago by kamleshpant

I am using following code to save data in table enumerations

$categoryName = $request->input('category_name');
        $department_id = $request->input('department_id');
        $category = new Enumerations();
        $category->name = $categoryName;
        $category->department_id = $department_id;
        $category->type = Enumerations::TYPE_CATEGORY;
        $category->save();

my table structure is

CREATE TABLE enumerations ( id int(11) unsigned NOT NULL AUTO_INCREMENT, name varchar(30) NOT NULL DEFAULT '', is_default tinyint(1) NOT NULL DEFAULT '0', department_id bigint unsigned NOT NULL, type varchar(255) DEFAULT NULL, active tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (id), CONSTRAINT fk_enumerations_department FOREIGN KEY (department_id) REFERENCES department (id), KEY idx_enumerations_on_id_and_type (id,type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

while saving i am getting following error

Column not found: 1054 Unknown column 'created_by' in 'field list' (SQL: insert into `enumerations` (`name`, `department_id`, `type`, `created_by`, `updated_by`, `updated_at`, `created_at`) values (testing cat, 4, 1, 1:Admin, 1:Admin, 2017-09-01 11:48:27, 2017-09-01 11:48:27))

can anyone help?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.