2
0

DictInfoController.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\DictInfo;
  4. use Illuminate\Http\Request;
  5. use App\Http\Resources\DictInfoResource;
  6. class DictInfoController extends Controller
  7. {
  8. /**
  9. * Display a listing of the resource.
  10. *
  11. * @return \Illuminate\Http\Response
  12. */
  13. public function index(Request $request)
  14. {
  15. //
  16. switch ($request->input('view')) {
  17. case 'name':
  18. $table = DictInfo::where('name', $request->input('name'));
  19. break;
  20. default:
  21. # code...
  22. break;
  23. }
  24. $table = $table->orderBy(
  25. $request->input('order', 'updated_at'),
  26. $request->input('dir', 'desc')
  27. );
  28. $table = $table->skip($request->input('offset', 0))
  29. ->take($request->input('limit', 100));
  30. $result = $table->get();
  31. $count = count($result);
  32. return $this->ok([
  33. "rows" => DictInfoResource::collection($result),
  34. "count" => $count
  35. ]);
  36. }
  37. /**
  38. * Store a newly created resource in storage.
  39. *
  40. * @param \Illuminate\Http\Request $request
  41. * @return \Illuminate\Http\Response
  42. */
  43. public function store(Request $request)
  44. {
  45. //
  46. }
  47. /**
  48. * Display the specified resource.
  49. *
  50. * @param \App\Models\DictInfo $dictInfo
  51. * @return \Illuminate\Http\Response
  52. */
  53. public function show(DictInfo $dictInfo)
  54. {
  55. //
  56. }
  57. /**
  58. * Update the specified resource in storage.
  59. *
  60. * @param \Illuminate\Http\Request $request
  61. * @param \App\Models\DictInfo $dictInfo
  62. * @return \Illuminate\Http\Response
  63. */
  64. public function update(Request $request, DictInfo $dictInfo)
  65. {
  66. //
  67. }
  68. /**
  69. * Remove the specified resource from storage.
  70. *
  71. * @param \App\Models\DictInfo $dictInfo
  72. * @return \Illuminate\Http\Response
  73. */
  74. public function destroy(DictInfo $dictInfo)
  75. {
  76. //
  77. }
  78. }