YqZsyTestService.php 643 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2019/1/11
  6. * Time: 9:50
  7. */
  8. namespace App\Modules\YunQi\Services;
  9. use App\Modules\YunQi\Models\YqZsyTest;
  10. class YqZsyTestService
  11. {
  12. public static function getRandomBooks($num=1):array{
  13. $books = YqZsyTest::select('bid')->where('type','yunqi')->get();
  14. if($books->count()<=0){
  15. return [];
  16. }
  17. $num = $books->count()>$num ?$num:$books->count();
  18. return $books->random($num)->pluck('bid')->all();
  19. }
  20. public static function getByBid($bid){
  21. return YqZsyTest::where('bid',$bid)->select('id','bid','type')->first();
  22. }
  23. }