如何修复此工厂代码和 return 用户 w/a 特定查询

How do I fix this factory code and return the users w/a specific query

$factory->define(App\Newsfeed::class, function (Faker $faker) {
    return [
        'owner_id' => function () {
            return App\User::where('role_id', 3)->orWhere('role_id', 5)->first()->id;
        },
        'newsfeed_title' => $faker->catchPhrase,
        'body' => $faker->sentence(8,false)
        ];
});

使用该代码,我想在两个查询之间获得随机结果,但我只得到第一个结果 w/ 是 user_id of 3

$factory->define(App\Newsfeed::class, function (Faker $faker) {
    return [
        'owner_id' => function () {
            return App\User::whereIn('role_id', [3, 5])->get()->random()->id;
        },
        'newsfeed_title' => $faker->catchPhrase,
        'body' => $faker->sentence(8,false)
    ];
});

应该能帮到你。