GamePlay.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Models;
  3. use DB;
  4. class GamePlay extends BaseModel
  5. {
  6. protected $table="game_play";
  7. public $timestamps = false;
  8. function getGamePlayList($list)
  9. {
  10. if(empty($list))
  11. {
  12. $list = 10;
  13. }
  14. $data = DB::table('game_play AS gp')
  15. ->select('gp.id','gp.name','gp.code','gp.bet_example','gp.sample_number','gp.sort','gc.name AS cate_name')
  16. ->leftJoin('game_category AS gc','gp.cate_id','=','gc.id')
  17. ->orderBy('gp.sort','desc')
  18. ->paginate($list);
  19. if(!$data){
  20. return -5040000522;//没有数据
  21. }
  22. return $data->toArray();
  23. }
  24. function getPlayOne($id){
  25. $data=$this->where('id',$id)->first();
  26. if(!$data){
  27. return -5040000622;
  28. }
  29. return $data->toArray();
  30. }
  31. //更新分类信息
  32. function updateOne($data,$id){
  33. $res=$this->where('id',$id)->update($data);
  34. if(!$res){
  35. return -5040000122;
  36. }
  37. return 1;
  38. }
  39. //检测是否存在
  40. function checkCopyPlay($cate,$code)
  41. {
  42. $data=$this->where('code',$code)->where('cate_id',$cate)->first();
  43. if(!$data){
  44. return 1;
  45. }
  46. return -5040451122;
  47. }
  48. function addPlay($data)
  49. {
  50. $res=$this->insert($data);
  51. if(!$res){
  52. return -5040001122;
  53. }
  54. }
  55. function getAll()
  56. {
  57. $data = $this->select('id','name')->orderBy('id','asc')->get()->toArray();
  58. if(!$data){
  59. return -5040000522;//没有数据
  60. }
  61. return $data;
  62. }
  63. }