LangController.php 872 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. $data['no_replace'] = 1;
  18. return $this->json($data);
  19. }
  20. public function getlang()
  21. {
  22. $data = Lang::getLang();
  23. return $this->json(['data' => $data, 'no_replace' => 1]);
  24. }
  25. function listUpdate()
  26. {
  27. $data = only('id,title,status,sort');
  28. if (!$data['id']) throw new ValidateException('参数错误');
  29. Lang::update($data);
  30. return $this->json(['msg' => '操作成功']);
  31. }
  32. }