0

i am having the error stated above, and here is the copy log

php artisan db:seed

   BadMethodCallException

  Call to undefined method AppModelsCategory::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 AppModelsCategory::toArray() ?

      +3 vendor frames
  4   database/seeders/DatabaseSeeder.php:38
      IlluminateDatabaseEloquentModel::__callStatic()

      +22 vendor frames
  27  artisan:37
      IlluminateFoundationConsoleKernel::handle()

here is the databaseseeder.php class since the error is there

<?php

namespace DatabaseSeeders;

use AppModelsCategory;
use AppModelsProduct;
use AppModelsTransaction;
use AppModelsUser;
use IlluminateDatabaseSeeder;

use IlluminateSupportFacadesDB;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        // AppModelsUser::factory(10)->create();

        DB::statement('SET FOREIGN_KEY_CHECKS=0');

        User::truncate();
        Category::truncate();
        Product::truncate();
        Transaction::truncate();
        DB::table('category_product')->truncate();

        $cantidadUsuarios = 200;
        $cantidadCategories = 30;
        $cantidadProductos = 1000;
        $cantidadTransacciones = 1000;

        AppModelsUser::factory()->count($cantidadUsuarios)->create();
        AppModelsCategory::factory()->count($cantidadUsuarios)->create();

        AppModelsProduct::factory()->count($cantidadTransacciones)->create()->each                                                                                           (
            function ($producto) {
                $categorias = Category::all()->random(mt_rand(1, 5))->pluck('id');
                $producto->categories()->attach($categorias);
            }
        );

        AppModelsTransaction::factory()->count($cantidadTransacciones)->create();
    }
}

there is the error line

AppModelsCategory::factory()->count($cantidadUsuarios)->create();

here we got the category class

<?php

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class Category extends Model
{
    public $table = "categories";

    protected $fillable = [
        'name',
        'description',
    ];
}

here we got the category factory

<?php

namespace DatabaseFactories;

use AppModelsCategory;
use IlluminateDatabaseEloquentFactoriesFactory;

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' => $this->faker->word,
            'description' => $this->faker->paragraph(1),
        ];
    }
}

here is the category migration

<?php

use AppModelsProduct;
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('description', 1000);
            $table->integer('quantity')->unsigned();
            $table->string('status')->default(Product::PRODUCTO_NO_DISPONIBLE);
            $table->string('image');
            $table->integer('seller_id')->unsigned();
            $table->timestamps();

            $table->foreign('seller_id')->references('id')->on('users');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('categories');
    }
}

i am posting all you need since i am a newbie on this and i cannot find the problem

thanks in foward