title: Call to undefined method App\Models\Category::factory() laravel
body: <p>I have the error stated above, and here is the copy log</p>
  <pre><code>php artisan db:seed
  
     BadMethodCallException
  
    Call to undefined method App\Models\Category::factory()
  
    at vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:50
       46▕      * @throws \BadMethodCallException
       47▕      */
       48▕     protected static function throwBadMethodCallException($method)
       49▕     {
    ➜  50▕         throw new BadMethodCallException(sprintf(
       51▕             'Call to undefined method %s::%s()', static::class, $method
       52▕         ));
       53▕     }
       54▕ }
  
    • Bad Method Call: Did you mean App\Models\Category::toArray() ?
  
        +3 vendor frames
    4   database/seeders/DatabaseSeeder.php:38
        Illuminate\Database\Eloquent\Model::__callStatic()
  
        +22 vendor frames
    27  artisan:37
        Illuminate\Foundation\Console\Kernel::handle()
  </code></pre>
  <p>Here is the databaseseeder.php class since the error is there:</p>
  <pre><code>&lt;?php
  
  namespace Database\Seeders;
  
  use App\Models\Category;
  use App\Models\Product;
  use App\Models\Transaction;
  use App\Models\User;
  use Illuminate\Database\Seeder;
  
  use Illuminate\Support\Facades\DB;
  
  class DatabaseSeeder extends Seeder
  {
      /**
       * Seed the application's database.
       *
       * @return void
       */
      public function run()
      {
          // \App\Models\User::factory(10)-&gt;create();
  
          DB::statement('SET FOREIGN_KEY_CHECKS=0');
  
          User::truncate();
          Category::truncate();
          Product::truncate();
          Transaction::truncate();
          DB::table('category_product')-&gt;truncate();
  
          $cantidadUsuarios = 200;
          $cantidadCategories = 30;
          $cantidadProductos = 1000;
          $cantidadTransacciones = 1000;
  
          \App\Models\User::factory()-&gt;count($cantidadUsuarios)-&gt;create();
          \App\Models\Category::factory()-&gt;count($cantidadUsuarios)-&gt;create();
  
          \App\Models\Product::factory()-&gt;count($cantidadTransacciones)-&gt;create()-&gt;each                                                                                           (
              function ($producto) {
                  $categorias = Category::all()-&gt;random(mt_rand(1, 5))-&gt;pluck('id');
                  $producto-&gt;categories()-&gt;attach($categorias);
              }
          );
  
          \App\Models\Transaction::factory()-&gt;count($cantidadTransacciones)-&gt;create();
      }
  }
  </code></pre>
  <p>There is the error line:</p>
  <pre><code>\App\Models\Category::factory()-&gt;count($cantidadUsuarios)-&gt;create();
  </code></pre>
  <p>Here we got the category class:</p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Database\Eloquent\Model;
  
  class Category extends Model
  {
      public $table = &quot;categories&quot;;
  
      protected $fillable = [
          'name',
          'description',
      ];
  }
  </code></pre>
  <p>Here we got the category factory:</p>
  <pre><code>&lt;?php
  
  namespace Database\Factories;
  
  use App\Models\Category;
  use Illuminate\Database\Eloquent\Factories\Factory;
  
  class CategoryFactory extends Factory
  {
      /**
       * The name of the factory's corresponding model.
       *
       * @var string
       */
      protected $model = Category::class;
  
      /**
       * Define the model's default state.
       *
       * @return array
       */
      public function definition()
      {
          return [
              //
               'name' =&gt; $this-&gt;faker-&gt;word,
              'description' =&gt; $this-&gt;faker-&gt;paragraph(1),
          ];
      }
  }
  </code></pre>
  <p>Here is the category migration:</p>
  <pre><code>&lt;?php
  
  use App\Models\Product;
  use Illuminate\Database\Migrations\Migration;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Support\Facades\Schema;
  
  class CreateCategoriesTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('categories', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('name');
              $table-&gt;string('description', 1000);
              $table-&gt;integer('quantity')-&gt;unsigned();
              $table-&gt;string('status')-&gt;default(Product::PRODUCTO_NO_DISPONIBLE);
              $table-&gt;string('image');
              $table-&gt;integer('seller_id')-&gt;unsigned();
              $table-&gt;timestamps();
  
              $table-&gt;foreign('seller_id')-&gt;references('id')-&gt;on('users');
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('categories');
      }
  }
  </code></pre>
  <p>I am posting all you need since I am new to this and I cannot find the problem.</p>