我想通过工厂和造假者将链接图像的插入数组插入到mongo-db
我的工厂:
$factory->define(App\Feed::class, function (Faker $faker)use ($fakerIR) {
return [
'title'=>$fakerIR->text(15),
'context'=>$fakerIR->text(),
'images'=>[$faker->imageUrl(), $faker->imageUrl(), $faker->imageUrl()],
'expires_at' => $faker->dateTimeBetween('now', '+1 months', 'Asia/Tehran'),
'writer_id' =>$faker->randomElement(\App\User::where('role','=','administrator')->get()->pluck('id')),
];
});
我也将图像投射到Feed模型中
protected $casts = [
'images' => 'array ',
'users_seen'=>'array'
];