database/seeds/DatabaseSeeder.php
/**
     * Seed the application's database.
     *
     * @return void
     */
Seed the application's database.
@return void
Seed the application ' s database . @return void
public function run()
    {
        $faker=Faker::create();
        $bob=new App\User();
        $bob->name="bob";
        $bob->email="bob@gmail.com";
        $bob->password=bcrypt("12345678");
        $bob->save();
        $alice=new App\User();
        $alice->name="alice";
        $alice->email="alice@gmail.com";
        $alice->password=bcrypt("12345678");
        $alice->save();
        $tom=new App\User();
        $tom->name="tom";
        $tom->email="tom@gmail.com";
        $tom->password=bcrypt("12345678");
        $tom->save();
        for($i=0;$i<15;$i++){
            $post=new App\Post();
            $post->title=$faker->sentence();
            $post->body=$faker->paragraph();
            $post->category_id=rand(1,5);
            $post->save();
        }
        for($i=0;$i<5;$i++){
            $category=new App\Category();
            $category->name=ucwords($faker->word());
            $category->save();
        }
        for($i=0;$i<25;$i++){
            $comment=new App\Comment();
            $comment->comment=$faker->paragraph();
            $comment->post_id=rand(1,15);
            $comment->user_id=rand(1,3);
            $comment->save();
        }
    }
public function run ( ) { $ faker = Faker :: create ( ) ; $ bob = new App \ User ( ) ; $ bob -> name = " bob " ; $ bob -> email = " bob@gmail.com " ; $ bob -> password = bcrypt ( " 12345678 " ) ; $ bob -> save ( ) ; $ alice = new App \ User ( ) ; $ alice -> name = " alice " ; $ alice -> email = " alice@gmail.com " ; $ alice -> password = bcrypt ( " 12345678 " ) ; $ alice -> save ( ) ; $ tom = new App \ User ( ) ; $ tom -> name = " tom " ; $ tom -> email = " tom@gmail.com " ; $ tom -> password = bcrypt ( " 12345678 " ) ; $ tom -> save ( ) ; for ( $ i = 0 ; $ i < 15 ; $ i ++ ) { $ post = new App \ Post ( ) ; $ post -> title = $ faker -> sentence ( ) ; $ post -> body = $ faker -> paragraph ( ) ; $ post -> category_id = rand ( 1 , 5 ) ; $ post -> save ( ) ; } for ( $ i = 0 ; $ i < 5 ; $ i ++ ) { $ category = new App \ Category ( ) ; $ category -> name = ucwords ( $ faker -> word ( ) ) ; $ category -> save ( ) ; } for ( $ i = 0 ; $ i < 25 ; $ i ++ ) { $ comment = new App \ Comment ( ) ; $ comment -> comment = $ faker -> paragraph ( ) ; $ comment -> post_id = rand ( 1 , 15 ) ; $ comment -> user_id = rand ( 1 , 3 ) ; $ comment -> save ( ) ; } }
Seed the application's database.
Seed the application ' s database .
// $this->call(UsersTableSeeder::class);