SystemRed.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Lenovo
  5. * Date: 2019/1/19
  6. * Time: 20:24
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\Log;
  10. use DB;
  11. class SystemRed extends BaseModel
  12. {
  13. protected $table = "system_red";
  14. public $timestamps = false;
  15. public function addSystemRed($data)
  16. {
  17. return $this->insert($data);
  18. }
  19. public function updateSystemRed($where,$data)
  20. {
  21. return $this->where($where)->update($data);
  22. }
  23. public function getSystemRedOne($where)
  24. {
  25. return $this->where($where)->first();
  26. }
  27. function getAll()
  28. {
  29. if(empty($list))
  30. {
  31. $list = 10;
  32. }
  33. $data = DB::table('system_red AS sr')
  34. ->select('sr.id','sr.red_num','sr.red_money','sr.status','sr.username','cr.room_name')
  35. ->leftJoin('chat_rooms AS cr','sr.room_id','=','cr.id')
  36. ->orderBy('sr.id','desc')
  37. ->paginate($list);
  38. if(!$data){
  39. return -5040000522;//没有数据
  40. }
  41. return $data->toArray();
  42. }
  43. public function checkRoom($room_id)
  44. {
  45. return $this->where("room_id",$room_id)->first();
  46. }
  47. }