SlideApi.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 老猫 <thinkcmf@126.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\api;
  12. use app\admin\model\SlideModel;
  13. use think\db\Query;
  14. class SlideApi
  15. {
  16. /**
  17. * 幻灯片模板数据源 用于模板设计
  18. * @param array $param
  19. * @return false|\PDOStatement|string|\think\Collection
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\ModelNotFoundException
  22. * @throws \think\exception\DbException
  23. */
  24. public function index($param = [])
  25. {
  26. $slideModel = new SlideModel();
  27. //返回的数据必须是数据集或数组,item里必须包括id,name,如果想表示层级关系请加上 parent_id
  28. return $slideModel
  29. ->where(function (Query $query) use ($param) {
  30. if (!empty($param['keyword'])) {
  31. $query->where('name', 'like', "%{$param['keyword']}%");
  32. }
  33. })->select();
  34. }
  35. }