GongzhonghaoController.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Http\Controllers\Mobile\Health;
  3. use App\Http\Controllers\Mobile\MobileBaseController;
  4. use App\Models\Article;
  5. use Illuminate\Http\Request;
  6. class GongzhonghaoController extends MobileBaseController
  7. {
  8. public function index(Request $request)
  9. {
  10. $size = 10;
  11. $key = $request->get('key', '');
  12. $where = [
  13. ['is_display','=',1],
  14. ['type_id','=',66],
  15. ];
  16. if (!empty($key)) {
  17. $where[] = ['title','like','%'.$key.'%'];
  18. }
  19. $rst = Article::where($where)
  20. ->orderBy('list_order', 'desc')
  21. ->orderBy('id', 'desc')
  22. ->paginate($size);
  23. if ($request->ajax()) {
  24. if ($rst->lastPage() < $rst->currentPage()) {
  25. return response()->json(['status' => 0]);
  26. }
  27. return response()->json(['status' => 1, 'data' => view('mobile.app.health.gongzhonghao.ajax_gongzhonghao_list', ['articles' => $rst])->render()]);
  28. }
  29. $mobile_dropload = false;
  30. if ($rst->total() > $size) {
  31. $mobile_dropload = true;
  32. }
  33. $return_data = [
  34. 'articles' => $rst,
  35. 'mobile_dropload' => $mobile_dropload,
  36. 'key' => $key,
  37. ];
  38. return view('mobile.app.health.gongzhonghao.index', $return_data);
  39. }
  40. }