with(['invoices'])->get(); return response()->json($suppliers); } /** * Store a newly created resource in storage. */ public function store(Request $request): JsonResponse { $supplierData = $request->validate([ 'name' => 'required|string', 'registration_name' => 'nullable|string', 'email' => 'nullable|email', 'address' => 'nullable|string', 'city' => 'nullable|string', 'zip' => 'nullable|string', 'country_code' => 'nullable|string', 'tax_fc' => 'nullable|string', 'tax_vat' => 'nullable|string', 'contact_name' => 'nullable|string', 'contact_phone' => 'nullable|string', 'contact_email' => 'nullable|string', ]); $supplier = new Supplier($supplierData); $supplier->save(); return response()->json($supplier); } /** * Update the specified resource in storage. */ public function update(Request $request, Supplier $supplier): JsonResponse { $supplierData = $request->validate([ 'name' => 'required|string', 'registration_name' => 'nullable|string', 'email' => 'nullable|email', 'address' => 'nullable|string', 'city' => 'nullable|string', 'zip' => 'nullable|string', 'country_code' => 'nullable|string', 'tax_fc' => 'nullable|string', 'tax_vat' => 'nullable|string', 'contact_name' => 'nullable|string', 'contact_phone' => 'nullable|string', 'contact_email' => 'nullable|string', ]); $supplier->update($supplierData); return response()->json($supplier); } }