ToolDecohelperLogic.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\logics;
  4. use app\model\ToolDecohelper;
  5. /**
  6. * 装修助手
  7. */
  8. class ToolDecohelperLogic
  9. {
  10. /**
  11. * 列表获取
  12. */
  13. public function list($where=[], $page=null, $limit=null)
  14. {
  15. $modelObj = ToolDecohelper::where($where);
  16. if(!is_null($page)) $modelObj->page($page);
  17. if(!is_null($limit)) $modelObj->limit($limit);
  18. $data = $modelObj->order('type,id')->select()->toArray();
  19. return $data;
  20. }
  21. /**
  22. * 总数获取
  23. */
  24. public function count($where=[])
  25. {
  26. $modelObj = ToolDecohelper::where($where);
  27. $num = $modelObj->count();
  28. return $num;
  29. }
  30. /**
  31. * 保存
  32. */
  33. public function save($data)
  34. {
  35. if (isset($data['id'])) {
  36. return ToolDecohelper::update($data);
  37. } else {
  38. return ToolDecohelper::create($data);
  39. }
  40. }
  41. /**
  42. * 删除
  43. */
  44. public function delete($id)
  45. {
  46. return ToolDecohelper::destroy($id);
  47. }
  48. /*
  49. * 获取单独post
  50. */
  51. public function getpost($title){
  52. return ToolDecohelper::where('title',$title)->find();
  53. }
  54. }