Lecturer.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\wap\model\special;
  12. use basic\ModelBasic;
  13. use traits\ModelTrait;
  14. use app\wap\model\merchant\Merchant;
  15. use app\wap\model\merchant\MerchantFollow;
  16. /**讲师 model
  17. * Class Lecturer
  18. * @package app\wap\model\special
  19. */
  20. class Lecturer extends ModelBasic
  21. {
  22. use ModelTrait;
  23. /**讲师列表
  24. * @param int $page
  25. * @param int $limit
  26. * @return array
  27. */
  28. public static function getLecturerList($uid, $page = 1, $limit = 10, $search = '')
  29. {
  30. $model = new self();
  31. if ($search != '') {
  32. $model = $model->where('lecturer_name', 'LIKE', "%$search%");
  33. }
  34. $data = $model->where(['is_del' => 0, 'is_show' => 1])->page((int)$page, (int)$limit)
  35. ->field('id,mer_id,lecturer_name,lecturer_head,label,curriculum,explain,study,sort,is_show,is_del')
  36. ->order('sort DESC,id DESC')->select();
  37. $data = count($data) > 0 ? $data->toArray() : [];
  38. foreach ($data as $key => &$value) {
  39. $value['is_follow'] = $uid > 0 ? MerchantFollow::isFollow($uid, $value['mer_id']) : false;
  40. $value['label'] = json_decode($value['label']);
  41. }
  42. return $data;
  43. }
  44. /**讲师详情
  45. * @param int $id
  46. */
  47. public static function details($id = 0)
  48. {
  49. $details = self::where(['is_del' => 0, 'is_show' => 1])->where('id', $id)->find();
  50. if ($details) {
  51. $details['label'] = json_decode($details['label']);
  52. $details['introduction'] = htmlspecialchars_decode($details['introduction']);
  53. return $details;
  54. } else {
  55. return null;
  56. }
  57. }
  58. public static function information($mer_id)
  59. {
  60. if (!$mer_id) return null;
  61. $lecturer_id = Merchant::where('id', $mer_id)->value('lecturer_id');
  62. $details = self::where(['is_del' => 0, 'is_show' => 1])->where('id', $lecturer_id)
  63. ->field('id,lecturer_name,lecturer_head,label')->find();
  64. if ($details) {
  65. $details['label'] = json_decode($details['label']);
  66. return $details;
  67. } else {
  68. return null;
  69. }
  70. }
  71. }