join('book_categories','book_categories.id','=','books.category_id') ->where('book_categories.channel_name',$channel_name) ->select('yq_zsy_test.bid')->where('type','yunqi')->get(); if($books->count()<=0){ return []; } $num = $books->count()>$num ?$num:$books->count(); return $books->random($num)->pluck('bid')->all(); } public static function getByBid($bid){ return YqZsyTest::where('bid',$bid)->select('id','bid','type')->first(); } }