Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

esorone's avatar

SQLSTATE[42S22]: Column not found: 1054 Unknown column

Hello all,

Sometimes I feel like king of the stupid questions, if I read your answers, but sometimes I have the feeling that im looking for a needle in a haystack and it turnout to be a Q instead of G..

Again I need your help.

I receive the " SQLSTATE[42S22]: Column not found: 1054 Unknown column 'amount' in 'field list' (SQL: insert into categories (amount, created_at, enddate, leveringsadres, startdate, tnv, updated_at, user_id) values (10, 2019-01-31 21:38:23, 2 019-01-29 17:06:37, teststraat 23, 2019-01-28 19:06:37, user1, 2019-01-31 21:38:23, 1))

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'amount' in 'field list

"

error when I run php artisan db:seed. Before i run this comment I always do a php artisan migrate:refresh.

Indeed, the column amount is not known in the categories table, because I'm not trying to seed into categories, but in checkouts.

I already tried to clear cache and reset migrations, composer dump-autoload etc. But still when I run php artisan db:seed I receive the mentioned error. I even tried to leave the '' 'amount' => '10', and wrote 'amount' => 10,. Just trail and error.

FYI the categories seeder works perfect.

I hope someone can help me out.

Please see my Seeder and Migration file.

Create Checkout table

class CreateCheckoutsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('checkouts', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('amount');
            $table->integer('user_id');
            $table->string('tnv');
            $table->string('leveringsadres');
            $table->date('startdate');
            $table->date('enddate');
            $table->timestamps();
        });
    }

Checkout Table Seeder.

class CheckoutTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $now = Carbon::now()->toDateTimeString();

        Category::insert([
            ['amount' => '10', 'user_id' => '1',
                'tnv' => 'user1', 'leveringsadres' => 'teststraat 23',
                'startdate' => '2019-01-28 19:06:37',
                'enddate' => '2019-01-29 17:06:37',
                'created_at' => $now, 'updated_at' => $now],
        ]);
    }
}

Create Categories Table

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('slug')->unique();
            $table->timestamps();
        });
    }

Categories Seeder.

class CategoriesTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $now = Carbon::now()->toDateTimeString();
        Category::insert([
            ['name' => 'Partijtent', 'slug' => 'partytent', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Ballonnen', 'slug' => 'ballon', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Springkussens', 'slug' => 'sprinkussen', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Stormbanen', 'slug' => 'stormbaan', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Geluid', 'slug' => 'geluid', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Overig', 'slug' => 'overig', 'created_at' => $now, 'updated_at' => $now],
        ]);
    }
}
0 likes
3 replies
D9705996's avatar
D9705996
Best Answer
Level 51

You trying to insert into the category table/model in your CheckoutTableSeeder

Category::insert([
...

The category model doesn't have an amount column hence the error. Try Checkout::insert instead.

munazzil's avatar

Check your database column exist or not because sometime may it has given as null.

esorone's avatar

Thanks D9705996

AHHHHH

I did even a search query for the name Category in VSCODE and still did not notice this one.

Please or to participate in this conversation.