I've got a foreign key of a user_id in my Listing table. In my ListingFactory I can put the user_id of a random user in that spot, but my user also has a is_seller bool. How can I make it so the query in my ListingFactory only gives me an array of users with is_seller=true? This is my code so far:
$factory->define(Listing::class, function (Faker $faker) {
$randomSellerId = \App\User::where('is_seller', true)->pluck('id')->toArray();
return [
'seller_id' => $faker->randomElement($randomSellerId),
];
});
This code still puts all the users, including the ones with is_seller=false, into the $randomSellerId
array