apl-mhd

database Seeder

Oct 18th, 2018
159
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Factory Class*/
  2.  
  3. use Faker\Generator as Faker;
  4.  
  5. //'post','title','user_id'];
  6. $factory->define(App\Model\Post::class, function (Faker $faker) {
  7.     return [
  8.         'user_id' => rand(2,10),
  9.         'title' => str_random(50),
  10.         'content' => str_random(200)
  11.     ];
  12. });
  13. /*seed class*/
  14. factory(Post::class,100)->create();
  15.  
  16. /*database class*/
  17.  
  18.   $this->call(PostsTableSeeder::class);
RAW Paste Data