QaPost.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/02
  6. */
  7. namespace app\admin\model\qa;
  8. use app\admin\model\store\StoreProduct;
  9. use app\admin\model\system\SystemAdmin;
  10. use app\models\user\User;
  11. use crmeb\traits\ModelTrait;
  12. use crmeb\basic\BaseModel;
  13. use app\admin\model\qa\QaReply;
  14. /**
  15. * 图文管理 Model
  16. * Class WechatNews
  17. * @package app\admin\model\wechat
  18. */
  19. class QaPost extends BaseModel
  20. {
  21. use ModelTrait;
  22. protected $name = 'qa_post';
  23. /**
  24. * 获取问答列表
  25. * @param array $where
  26. * @return array
  27. */
  28. public static function getAll($where = [])
  29. {
  30. $model = new self;
  31. if ($where['status'] !== '') $model = $model->where('status', $where['status']);
  32. // if($where['access'] !== '') $model = $model->where('access',$where['access']);
  33. if ($where['title'] !== '') $model = $model->where('title', 'LIKE', "%$where[title]%");
  34. $model = $model->where('is_del', 0)->order('id desc');
  35. return self::page($model, function ($item) {
  36. $item['nickname'] = $item['uid']?User::where('uid', $item['uid'])->value('nickname'):'后台';
  37. // $img=explode(';',$item['img_list']);
  38. $img = json_decode($item['img_list'], true);;
  39. $item['img'] = $img[0];
  40. }, $where);
  41. }
  42. /**
  43. * 删除问答
  44. * @param $id
  45. * @return bool
  46. */
  47. public static function del($id)
  48. {
  49. return self::edit(['is_del' => 1], $id, 'id');
  50. }
  51. public static function changeFail($id)
  52. {
  53. return self::edit(['status' => 2], $id, 'id');
  54. }
  55. public static function changeSuccess($id)
  56. {
  57. return self::edit(['status' => 1], $id, 'id');
  58. }
  59. }