IntelligenceProduct.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\admin\model;
  3. use support\Db;
  4. use support\Model;
  5. /**
  6. * 角色模型
  7. * Class Users
  8. * @package app\admin\model
  9. */
  10. class IntelligenceProduct extends Model
  11. {
  12. /**
  13. * The table associated with the model.
  14. *
  15. * @var string
  16. */
  17. protected $table = 'intelligence_products';
  18. public $timestamps = false;
  19. /**
  20. * Notes:获取智能产品列表
  21. * @param string $keywords
  22. * @param int $page
  23. * @param int $limit
  24. * @return array
  25. * User: ZQ
  26. * Date: 2022/9/13
  27. */
  28. public static function getProductList(int $page, int $limit, string $keywords)
  29. {
  30. $list = static::select(['intelligence_products.*','intelligence_category.category_name'])
  31. ->where(['product_del'=>0])
  32. ->when($keywords != '', function ($query) use ($keywords){
  33. $query->where('product_name', 'like', '%' . $keywords . '%');
  34. })
  35. ->leftJoin('intelligence_category', 'category_id', '=', 'intelligence_products.product_category_id')
  36. ->orderBy('product_create_time','DESC')
  37. ->forPage($page, $limit)
  38. ->get();
  39. $count = static::where(['product_del'=>0])
  40. ->when($keywords != '', function ($query) use ($keywords){
  41. $query->where('product_name', 'like', '%' . $keywords . '%');
  42. })
  43. ->count();
  44. return [$list, $count];
  45. }
  46. /**
  47. * Notes:获取角色列表
  48. * @return array
  49. * User: ZQ
  50. * Date: 2022/9/19`
  51. */
  52. public static function getRoleAll()
  53. {
  54. $list = static::select(['role_id','role_name'])
  55. ->where(['role_status'=>1])
  56. ->orderBy('role_create_time','DESC')
  57. ->get();
  58. return $list;
  59. }
  60. }