在laravel和我的播种机中使用faker我有
public function run()
{
$faker = new Faker\Generator();
//create a user
$adminuser = App\User::create(
[
'name' => 'admin',
'first_name' => 'firstuser',
'profile_pic'=>$faker->image('storage/app/public/users',400,300, 'people', false),
]
);
但现在收到错误
Unknown formatter "image"
我哪里出错
我只想将图像添加到通过faker生成的用户
答案 0 :(得分:2)
minLength: (!isNaN(parseFloat(n)) && isFinite(n)) ? 1 : 3
答案 1 :(得分:1)
您必须使用Method Injection
例如:
<?php
use Illuminate\Database\Seeder;
use Faker\Generator as Faker;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @param Faker $faker
* @return void
*/
public function run(Faker $faker)
{
$adminuser = App\User::create(
[
'name' => $faker->name,
'first_name' => $faker->firstName,
'profile_pic' => $faker->image(public_path('img'),400,300, 'people', true),
]
);
}
}