StockProductController.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\StockProduct;
  4. use App\Services\FunctionService;
  5. use Illuminate\Http\Request;
  6. class StockProductController extends Controller
  7. {
  8. public function __construct()
  9. {
  10. $this->authorizeResource(StockProduct::class);
  11. }
  12. /**
  13. * Display a listing of the resource.
  14. *
  15. * @return \Illuminate\Http\Response
  16. */
  17. public function index()
  18. {
  19. return inertia("StockProducts/Index", [
  20. "initialFilters" => request()->only("search"),
  21. "stockProducts" => StockProduct::search(request()->only("search"))
  22. ->latest()
  23. ->paginate(10)
  24. ->withQueryString()
  25. ->through(
  26. fn($stockProduct) => [
  27. "id" => $stockProduct->id,
  28. "updatedAt" => $stockProduct->updated_at,
  29. "name" => $stockProduct->product->name,
  30. "price" => FunctionService::rupiahFormat(
  31. $stockProduct->price
  32. ),
  33. "qty" => $stockProduct->qty,
  34. "unit" => $stockProduct->product->unit,
  35. ]
  36. ),
  37. ]);
  38. }
  39. /**
  40. * Show the form for creating a new resource.
  41. *
  42. * @return \Illuminate\Http\Response
  43. */
  44. public function create()
  45. {
  46. //
  47. }
  48. /**
  49. * Store a newly created resource in storage.
  50. *
  51. * @param \Illuminate\Http\Request $request
  52. * @return \Illuminate\Http\Response
  53. */
  54. public function store(Request $request)
  55. {
  56. //
  57. }
  58. /**
  59. * Display the specified resource.
  60. *
  61. * @param int $id
  62. * @return \Illuminate\Http\Response
  63. */
  64. public function show($id)
  65. {
  66. //
  67. }
  68. /**
  69. * Show the form for editing the specified resource.
  70. *
  71. * @param int $id
  72. * @return \Illuminate\Http\Response
  73. */
  74. public function edit($id)
  75. {
  76. //
  77. }
  78. /**
  79. * Update the specified resource in storage.
  80. *
  81. * @param \Illuminate\Http\Request $request
  82. * @param int $id
  83. * @return \Illuminate\Http\Response
  84. */
  85. public function update(Request $request, $id)
  86. {
  87. //
  88. }
  89. /**
  90. * Remove the specified resource from storage.
  91. *
  92. * @param int $id
  93. * @return \Illuminate\Http\Response
  94. */
  95. public function destroy($id)
  96. {
  97. //
  98. }
  99. }