Skip to content

Instantly share code, notes, and snippets.

@marufmax
Created March 30, 2018 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marufmax/7b8d58a2fcc77d6ba270abda52f74d22 to your computer and use it in GitHub Desktop.
Save marufmax/7b8d58a2fcc77d6ba270abda52f74d22 to your computer and use it in GitHub Desktop.
Products Table Seeder with Faker (Fake Data) - Laravel
<?php
use Illuminate\Database\Seeder;
use App\Product;
use Faker\Factory as Faker;
class ProductsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
foreach (range(1, 200) as $index) {
DB::table('products')->insert([
'name' => $faker->city,
'slug' => $faker->unique()->slug,
'details' => $faker->paragraph($nb =2),
'price' => $faker->numberBetween($min = 500, $max = 8000),
'description'=> $faker->paragraph($nb =8)
]);
}
}
}
@arinzehills
Copy link

what of the column for the images sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment