Home > Mobile >  sqlstate[42s22]: column not found: 1054 unknown column 'description' in 'field list&#
sqlstate[42s22]: column not found: 1054 unknown column 'description' in 'field list&#

Time:06-13

<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

class ListingFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
              'title' => $this->faker->sentence(),
              'tags' => 'laravel, api, backend',
              'company' => $this->faker->company(),
              'email' => $this->faker->companyEmail(),
              'website' => $this->faker->url(),
              'location' => $this->faker->city(),
              'description' => $this->faker->paragraph(2)
        ];
    }
}

this is the error it brings:

sqlstate[42s22]: column not found: 1054 unknown column 'description' in 'field list' (sql: insert into listings (title, tags, company, location, email, website, description, updated_at, created_at) values

CodePudding user response:

You are missing it from the migration, please add

 
$schema->string('description')->nullable()
 

inside your database migration file located in database/migrations/<date_and_table_name>.php and run php artisan migrate:refresh or equivalent database migration command again.

  • Related