LangController.php 826 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\admin\controller;
  3. use think\exception\ValidateException;
  4. use app\model\Lang;
  5. class LangController extends Base
  6. {
  7. function index()
  8. {
  9. $keyword = input('post.keyword', '', 'serach_in');
  10. $query = Lang::where(['weid' => weid()]);
  11. Lang::datainitial();
  12. if (!empty($keyword)) {
  13. $query->where('title', 'like', '%' . $keyword . '%');
  14. }
  15. $Langdata = $query->order('sort asc,id asc')->select()->toArray();
  16. $data['data'] = $Langdata;
  17. return $this->json($data);
  18. }
  19. public function getlang()
  20. {
  21. $data = Lang::getLang();
  22. return $this->json(['data' => $data]);
  23. }
  24. function listUpdate()
  25. {
  26. $data = only('id,title,status,sort');
  27. if (!$data['id']) throw new ValidateException('参数错误');
  28. Lang::update($data);
  29. return $this->json(['msg' => '操作成功']);
  30. }
  31. }