DailyWechatArticleLogic.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\logics;
  4. use app\model\DailyWechatArticle as Model;
  5. class DailyWechatArticleLogic
  6. {
  7. /**
  8. * 每日发圈列表
  9. */
  10. public function list($where, $page=null, $limit=null, $order=null)
  11. {
  12. $modelObj = Model::with(['dailyWechatLabel'])->where($where);
  13. if(!is_null($page)) $modelObj->page((int)$page);
  14. if(!is_null($limit)) $modelObj->limit((int)$limit);
  15. if(!is_null($order)) $modelObj->order($order);
  16. $data = $modelObj->select()->toArray();
  17. return $data;
  18. }
  19. /**
  20. * 总数获取
  21. */
  22. public function count($where)
  23. {
  24. $modelObj = Model::where($where);
  25. $num = $modelObj->count();
  26. return $num;
  27. }
  28. /**
  29. * 添加每日发圈内容
  30. */
  31. public function addArticle($data)
  32. {
  33. Model::insert($data);
  34. }
  35. /**
  36. * 内容上下架
  37. */
  38. public function shelf($id)
  39. {
  40. $shelf = Model::where('id', $id)->value('shelf');
  41. $shelf = $shelf == 1 ? 0 : 1;
  42. Model::where('id',$id)->setField('shelf',$shelf);
  43. }
  44. /**
  45. * 删除每日发圈内容
  46. */
  47. public function del($id)
  48. {
  49. Model::where('id',$id)->setField('del',1);
  50. }
  51. /**
  52. * 内容编辑
  53. */
  54. public function edit($id)
  55. {
  56. $data = Model::where('id', $id)->find();
  57. return $data;
  58. }
  59. /**
  60. * 内容编辑保存
  61. */
  62. public function save($data)
  63. {
  64. Model::where('id', $data['id'])->update($data);
  65. }
  66. }