SystemBusiness.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\admin\model;
  3. use support\Model;
  4. /**
  5. * 业务控制器模型
  6. * Class SystemAdmin
  7. * @package app\admin\model
  8. */
  9. class SystemBusiness extends Model
  10. {
  11. /**
  12. * The table associated with the model.
  13. *
  14. * @var string
  15. */
  16. protected $table = 'system_business';
  17. public $timestamps = false;
  18. /**
  19. * Notes:获取业务控制器列表
  20. * @param string $keywords
  21. * @param int $page
  22. * @param int $limit
  23. * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
  24. * User: ZQ
  25. * Date: 2022/11/17
  26. */
  27. public static function businessList(string $keywords, int $page, int $limit)
  28. {
  29. $list = static::select('*')
  30. ->when($keywords != '', function ($query) use ($keywords){
  31. $query->where('business_name', 'like', '%' . $keywords . '%');
  32. })
  33. ->orderBy('business_time','DESC')
  34. ->forPage($page, $limit)
  35. ->get();
  36. $count = static::
  37. when($keywords != '', function ($query) use ($keywords){
  38. $query->where('business_name', 'like', '%' . $keywords . '%');
  39. })
  40. ->count();
  41. return [$list, $count];
  42. }
  43. public static function businessUpdate($business)
  44. {
  45. return static::where('uid', '>', 0)->update($business);
  46. }
  47. }