ParkingFeeController.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Requests\ParkingFee\StoreParkingFeeRequest;
  4. use App\Models\ParkingFee;
  5. use Illuminate\Http\Request;
  6. class ParkingFeeController extends Controller
  7. {
  8. public function __construct()
  9. {
  10. $this->authorizeResource(ParkingFee::class);
  11. }
  12. /**
  13. * Display a listing of the resource.
  14. *
  15. * @return \Illuminate\Http\Response
  16. */
  17. public function index()
  18. {
  19. //
  20. }
  21. /**
  22. * Show the form for creating a new resource.
  23. *
  24. * @return \Inertia\Response
  25. */
  26. public function create()
  27. {
  28. $parkingFees = ParkingFee::get()->transform(fn($parkingFee) => [
  29. 'id' => $parkingFee->id,
  30. 'price' => $parkingFee->price,
  31. 'timePeriod' => $parkingFee->time_period,
  32. ]);
  33. return inertia('parkingfee/Create', compact('parkingFees'));
  34. }
  35. /**
  36. * Store a newly created resource in storage.
  37. *
  38. * @param \Illuminate\Http\Request $request
  39. * @return \Illuminate\Http\Response
  40. */
  41. public function store(StoreParkingFeeRequest $request)
  42. {
  43. foreach ($request->id as $key => $id) {
  44. ParkingFee::upsert([
  45. 'id' => $id,
  46. 'time_period' => $request->time_period[$key],
  47. 'price' => $request->price[$key],
  48. ], ['id']);
  49. }
  50. return back()->with('success', __('messages.success.store.parking_fee'));
  51. }
  52. /**
  53. * Display the specified resource.
  54. *
  55. * @param int $id
  56. * @return \Illuminate\Http\Response
  57. */
  58. public function show($id)
  59. {
  60. //
  61. }
  62. /**
  63. * Show the form for editing the specified resource.
  64. *
  65. * @param int $id
  66. * @return \Illuminate\Http\Response
  67. */
  68. public function edit($id)
  69. {
  70. //
  71. }
  72. /**
  73. * Update the specified resource in storage.
  74. *
  75. * @param \Illuminate\Http\Request $request
  76. * @param int $id
  77. * @return \Illuminate\Http\Response
  78. */
  79. public function update(Request $request, $id)
  80. {
  81. //
  82. }
  83. /**
  84. * Remove the specified resource from storage.
  85. *
  86. * @param int $id
  87. * @return \Illuminate\Http\Response
  88. */
  89. public function destroy($id)
  90. {
  91. //
  92. }
  93. }