in Laravel migration i have this line :
$table->tinyInteger('action_type')->index();
and when i try to save data in the table like with this code:
ActionsLog::create([
'account_id' => auth()->user()->id,
'action_type' => 1, //like
'log', $ex->getMessage()
]);
laravel couldn't return third column which that name is action_type
and i get this error:
Column not found: 1054 Unknown column '1' in 'field list' (SQL: insert into `actions_logs` (`account_id`, `action_type`, `1`, `updated_at`, `created_at`) values (2, 1, SQLSTATE[42S22]: Column not found: 1054 Unknown column '1' in 'field list' (SQL: insert into `actions_logs` (`account_id`, `action_type`, `1`, `updated_at`, `created_at`) values (2, 1, Use of undefined constant ture - assumed 'ture' (this will throw an Error in a future version of PHP), 2018-07-11 07:50:18, 2018-07-11 07:50:18)), 2018-07-11 07:50:18, 2018-07-11 07:50:18))
My migration file:
public function up()
{
Schema::create('actions_logs', function (Blueprint $table) {
$table->increments('id');
$table->integer('account_id')->unsigned();
$table->foreign('account_id')->references('id')->on('instagram_actions_histories')->onDelete('cascade');
$table->tinyInteger('action_type')->index();
$table->text('log');
$table->timestamps();
});
}
Problem is with line 'log', $ex->getMessage()
. Change ,
in this line to =>
. Replace code as:
ActionsLog::create([
'account_id' => auth()->user()->id,
'action_type' => 1,
'log' => $ex->getMessage()
]);