Created
March 30, 2018 20:49
-
-
Save marufmax/7b8d58a2fcc77d6ba270abda52f74d22 to your computer and use it in GitHub Desktop.
Products Table Seeder with Faker (Fake Data) - Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) | |
]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what of the column for the images sir