Appointment.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 Appointment extends Model
  11. {
  12. /**
  13. * The table associated with the model.
  14. *
  15. * @var string
  16. */
  17. protected $table = 'medical_care_appointment';
  18. public $timestamps = false;
  19. /**
  20. * Notes:获取产品列表
  21. * @param string $keywords
  22. * @param int $page
  23. * @param int $limit
  24. * @return array
  25. * User: QJF
  26. * Date: 2022/9/23
  27. */
  28. public static function geMentList(int $page, int $limit,$keywords)
  29. {
  30. $list = static::select('*')
  31. ->with(['Category','Shop'])
  32. ->when($keywords != '', function ($query) use ($keywords){
  33. $query->where('appointment_name', 'like', '%' . $keywords . '%');
  34. })
  35. ->where('appointment_del',0)
  36. ->orderBy('appointment_create_time','DESC')
  37. ->forPage($page, $limit)
  38. ->get();
  39. $count = static::when($keywords != '', function ($query) use ($keywords){
  40. $query->where('appointment_name', 'like', '%' . $keywords . '%');
  41. }) ->where('appointment_del',0)->count();
  42. return [$list, $count];
  43. }
  44. public function getAppointmentCreateTimeAttribute($value)
  45. {
  46. return date('Y-m-d H:i:s', $value);
  47. }
  48. public function Category(){
  49. return $this->belongsTo(Category::class,'appointment_category_id','category_id');
  50. }
  51. //关联店铺
  52. public function Shop(){
  53. return $this->belongsTo(MerchantShop::class,'appointment_shop_id','shop_id');
  54. }
  55. }