ngavanozov
While generate random data, I get an error: join(): Passing glue string after array is deprecated. Swap the parameters .../plugins/rahman/faker/vendor/fzaninotto/faker/src/Faker/Provider/Lorem.php line 95
ngavanozov
Hi, this is in routes.php in my plugin:
Route::get('/populate-products', function() { $faker = Faker\Factory::create();
/* Categories */
for($i = 0; $i < 5; $i++) {
$title = $faker->sentence($nbWords = 1, $variableNbWords = true);
$caregory = new Category;
$caregory->title = $title;
$caregory->slug = str_slug($title, '-');
$caregory->description = $faker->paragraph($nbSentences = 3, $variableNbSentences = true);
$caregory->active = true;
$caregory->show_in_menu = true;
$caregory->save();
}
/* Brands */
for($i = 0; $i < 9; $i++) {
$title = $faker->sentence($nbWords = 2, $variableNbWords = true);
$brand = new Brand;
$brand->title = $title;
$brand->slug = str_slug($title, '-');
$brand->description = $faker->paragraph($nbSentences = 3, $variableNbSentences = true);
$brand->active = true;
$brand->created_at = $faker->date($format = 'Y-m-d H:i:s', $max = 'now');
$brand->save();
}
/* Tags */
for($i = 0; $i < 20; $i++) {
$title = $faker->sentence($nbWords = 1, $variableNbWords = true);
$tag = new Tag;
$tag->title = $title;
$tag->slug = str_slug($title, '-');
$tag->color = $faker->hexcolor();
$tag->save();
}
/* Products */
$categories = Category::lists('id');
$brands = Brand::lists('id');
$tags = Tag::lists('id');
for($i = 0; $i < 66; $i++) {
$title = $faker->sentence($nbWords = 3, $variableNbWords = true);
$product = new Product;
$product->title = $title;
$product->slug = str_slug($title, '-');
$product->short_description = $faker->paragraph($nbSentences = 1, $variableNbSentences = true);
$product->description = $faker->paragraph($nbSentences = 3, $variableNbSentences = true);
$product->category_id = $faker->randomElement($categories);
$product->brand_id = $faker->randomElement($brands);
$product->tags = $faker->randomElement($tags, $count = 3);
$product->active = true;
$product->available = $faker->boolean($chanceOfGettingTrue = 80);
$product->barcode = $faker->isbn10();
$product->created_at = $faker->date($format = 'Y-m-d H:i:s', $max = 'now');
$product->save();
}
return Redirect::to('/');
});
Last updated
1-4 of 4