Navigation.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Navigation extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 获取导航列表
  16. * @access public
  17. * @author csdeshang
  18. * @param array $condition 条件
  19. * @param int $pagesize 分页
  20. * @param string $order 排序
  21. * @return array
  22. */
  23. public function getNavigationList($condition, $pagesize = '', $order = 'nav_sort desc')
  24. {
  25. if ($pagesize) {
  26. $nav_list = Db::name('navigation')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  27. $this->page_info = $nav_list;
  28. return $nav_list->items();
  29. } else {
  30. return Db::name('navigation')->where($condition)->order('nav_sort')->select()->toArray();
  31. }
  32. }
  33. /**
  34. * 新增导航
  35. * @access public
  36. * @author csdeshang
  37. * @param type $data 参数内容
  38. * @return bool
  39. */
  40. public function addNavigation($data)
  41. {
  42. $add_navigation = Db::name('navigation')->insert($data);
  43. return $add_navigation;
  44. }
  45. /**
  46. * 编辑导航
  47. * @access public
  48. * @author csdeshang
  49. * @param type $data 数据
  50. * @param type $condition 条件
  51. * @return bool
  52. */
  53. public function eidtNavigation($data, $condition)
  54. {
  55. return Db::name('navigation')->where($condition)->update($data);
  56. }
  57. /**
  58. * 获取单个导航
  59. * @access public
  60. * @author csdeshang
  61. * @param type $condition 条件
  62. * @return array
  63. */
  64. public function getOneNavigation($condition)
  65. {
  66. return Db::name('navigation')->where($condition)->find();
  67. }
  68. /**
  69. * 删除导航
  70. * @access public
  71. * @author csdeshang
  72. * @param type $condition 条件
  73. * @return bool
  74. */
  75. public function delNavigation($condition)
  76. {
  77. return Db::name('navigation')->where($condition)->delete();
  78. }
  79. }