validate([ 'full_name' => 'string|max:255', 'tax_number' => 'nullable|integer', 'social_security_number' => 'nullable|integer', 'description' => 'nullable|string|max:500' ]); $person->update($attributes); return response()->json([ 'person' => [ 'full_name' => $person->full_name, 'tax_number' => $person->tax_number, 'social_security_number' => $person->social_security_number, 'description' => $person->description ] ]); } public function createAddress(Person $person, Request $request){ $attributes = $request->validate([ 'address' => 'required|string|max:150', 'country' => 'nullable|string', 'type_id' => 'required|integer|exists:address_types,id', 'description' => 'nullable|string|max:125' ]); $address_id = $person->addresses()->create($attributes)->id; return response()->json([ 'address' => \App\Models\Person\PersonAddress::with(['type'])->findOrFail($address_id) ]); } public function updateAddress(Person $person, int $address_id, Request $request) { $attributes = $request->validate([ 'address' => 'required|string|max:150', 'country' => 'nullable|string', 'type_id' => 'required|integer|exists:address_types,id', 'description' => 'nullable|string|max:125' ]); $address = $person->addresses()->with(['type'])->findOrFail($address_id); $address->update($attributes); return response()->json([ 'address' => $address ]); } public function createPhone(Person $person, Request $request) { $attributes = $request->validate([ 'nu' => 'required|string|max:50', 'country_code' => 'nullable|integer', 'type_id' => 'required|integer|exists:phone_types,id', 'description' => 'nullable|string|max:125' ]); $phone_id = $person->phones()->create($attributes)->id; return response()->json([ 'phone' => \App\Models\Person\PersonPhone::with(['type'])->findOrFail($phone_id) ]); } public function updatePhone(Person $person, int $phone_id, Request $request) { $attributes = $request->validate([ 'nu' => 'required|string|max:50', 'country_code' => 'nullable|integer', 'type_id' => 'required|integer|exists:phone_types,id', 'description' => 'nullable|string|max:125' ]); $phone = $person->phones()->with(['type'])->findOrFail($phone_id); $phone->update($attributes); return response()->json([ 'phone' => $phone ]); } }