Use of Seeder and Faker in Laravel

PHOTO EMBED

Sat Oct 08 2022 16:05:01 GMT+0000 (Coordinated Universal Time)

Saved by @ahmad007 #laravel #ajax

----------Terminal Command------------------------
php artisan make:seeder BookSeeder
----------BookSeeder Code---------------------------
  use Faker\Factory as Faker;
----------Public function run() code------------------
 $faker = Faker::create();
       for ($i=0; $i < 100; $i++) { 
            $book = new Book;
            $book->book_name = $faker->name;
            $book->book_author = $faker->city;
            $book->save();
        }
----------Database Seeder code public function run()---------------
   $this->call([
            BookSeeder::class
        ]);
------------------php artisan code--------------------------------
php artisan db:seed
content_copyCOPY