jet
125
3
Laravel

Call to undefined function create()

Posted 5 months ago by jet

this is the PostsTableSeeder

<?php

use Illuminate\Database\Seeder;

class PostsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        factory(App\Post::class, 30)-create();
    }
}

DatabaseSeeder

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
         $this->call(PostsTableSeeder::class);
    }
}

PostsFactory

use Faker\Generator as Faker;

$factory->define(Post::class, function (Faker $faker) {

    return [
        'title' => $faker->sentence(50),
        'category_id' => $faker->text(50),
        'content' => $faker->paragraph(50),
        'order' => $faker->text(50),
        'views' => $faker->text(50),
        'status' => $faker->text(50),
        'slug' => $faker->url(50),
        'meta ' => $faker->text(50),

    ];
});

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.