StationRuleBatchController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Components\AsyncResponse;
  4. use App\Http\Requests\Station\StationRuleBatchRequest;
  5. use App\Services\OwnerService;
  6. use App\Station;
  7. use App\StationRuleBatch;
  8. use Illuminate\Contracts\Foundation\Application;
  9. use Illuminate\Contracts\View\Factory;
  10. use Illuminate\Http\Request;
  11. use Illuminate\Http\Response;
  12. use Illuminate\View\View;
  13. class StationRuleBatchController extends Controller
  14. {
  15. use AsyncResponse;
  16. /**
  17. * Display a listing of the resource.
  18. *
  19. * @param Request $request
  20. * @param OwnerService $ownerService
  21. * @return Application|Factory|View
  22. */
  23. public function index(Request $request,OwnerService $ownerService)
  24. {
  25. $stationRuleBatches = StationRuleBatch::query()->with('stationType','owner')->orderByDesc('id')->paginate($request['paginate'] ?? 50);
  26. $owners = $ownerService->getAuthorizedOwners();
  27. return view('station.rule.index',compact('stationRuleBatches','owners'));
  28. }
  29. /**
  30. * store API
  31. * @param StationRuleBatchRequest $request
  32. */
  33. public function storeApi(StationRuleBatchRequest $request)
  34. {
  35. $stationRuleBatch = StationRuleBatch::query()->create($request->only(['name','owner_id']));
  36. $stationRuleBatch->load('stationType','owner');
  37. $this->success($stationRuleBatch);
  38. }
  39. /**
  40. * update API
  41. * @param StationRuleBatchRequest $request
  42. */
  43. public function updateApi(StationRuleBatchRequest $request)
  44. {
  45. $stationRuleBatch = StationRuleBatch::query()->whereKey($request['id'])->first();
  46. $stationRuleBatch->update($request->all());
  47. $stationRuleBatch->load('stationType','owner');
  48. $this->success($stationRuleBatch);
  49. }
  50. public function destroyApi(Request $request)
  51. {
  52. StationRuleBatch::query()->whereKey($request['id'])->delete();
  53. $this->success();
  54. }
  55. /**
  56. * Show the form for creating a new resource.
  57. *
  58. * @return Response
  59. */
  60. public function create()
  61. {
  62. //
  63. }
  64. /**
  65. * Store a newly created resource in storage.
  66. *
  67. * @param \Illuminate\Http\Request $request
  68. * @return Response
  69. */
  70. public function store(Request $request)
  71. {
  72. //
  73. }
  74. /**
  75. * Display the specified resource.
  76. *
  77. * @param \App\StationRuleBatch $stationRuleBatch
  78. * @return Response
  79. */
  80. public function show(StationRuleBatch $stationRuleBatch)
  81. {
  82. //
  83. }
  84. /**
  85. * Show the form for editing the specified resource.
  86. *
  87. * @param \App\StationRuleBatch $stationRuleBatch
  88. * @return Response
  89. */
  90. public function edit(StationRuleBatch $stationRuleBatch)
  91. {
  92. //
  93. }
  94. /**
  95. * Update the specified resource in storage.
  96. *
  97. * @param \Illuminate\Http\Request $request
  98. * @param \App\StationRuleBatch $stationRuleBatch
  99. * @return Response
  100. */
  101. public function update(Request $request, StationRuleBatch $stationRuleBatch)
  102. {
  103. //
  104. }
  105. /**
  106. * Remove the specified resource from storage.
  107. *
  108. * @param \App\StationRuleBatch $stationRuleBatch
  109. * @return Response
  110. */
  111. public function destroy(StationRuleBatch $stationRuleBatch)
  112. {
  113. //
  114. }
  115. }