$varient = Varient::pluck('id')->toArray();
return [
'name' => fake()->imageUrl(),
'varient_id' => fake()->randomElement($varient)
];
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey guys
I want to full table posts with some data in table users with faker.
this is my code
postsFactory.php :
$users = users::select('id')->get();
return [
'userId' => fake()->shuffle(array($users)),
'postBody' => fake()->text(),
];
I want to get all user's Id from user table and save it to posts table in userId's column. I'm looking for something like this. [1,2,3,4,5,9,...]. It's not work. I did same thing in CI4 , but I can not do here, can anyone help me how to figure out this?
Tnx
Please or to participate in this conversation.