json(Component::all()->toJson()); } public function show($id) { $component = Component::find($id); if (!$component) { return response()->json(['message' => 'Component not found'], 404); } return response()->json($component); } public function create(Request $request) { $name = $request->get(key:'name'); $type = $request->get(key:'type'); $brand = $request->get(key:'brand'); $model = $request->get(key:'model'); $price = $request->get(key:'price'); $component = new Component(); $component->name = $name; $component->type = $type; $component->brand = $brand; $component->model = $model; $component->price = $price; $component->save(); return response()->json($component->toJson()); } }