« first day  last day (15 days later) » 

10:09 AM
@YongShun - Sorry for disturbing you again.
I changed my backend code to this, and was able to successfully submit into DB using POSTMAN:

if(!$employee) return $this->error('No Employee with ID '.$id, 404);
$employee->current_residential_address = $request->current_residential_address;
$employee->save();


$phone_numbers = $request->phone_number;
$phone_type_id = $request->phone_type_id;
$is_primary_contact_number = $request->is_primary_contact_number;
 
10:43 AM
@user11352561 I will recommend you to create another model in front-end, let say IEditEmployee
 
@YongShun - Can you give me a sample
 
this IEditEmployee has the same property as IEmployee, just now the difference is that IEditEmployee with phone_number attribute
To standardize that the Angular model has the same attributes/property as requested by back-end
For my suggestion, IEmployee which is for display Employee details as 1 model

Create/edit data use another model.
So won't mix up the model as they are used for different purposes and modify of the model (if use same model) will affect both actions (aimed for less dependencies).
 
That means I will still refence IContact for employeephones?
 
Yes
@user11352561 rename employeephones to phone_number as your back-end expect to decide $request with phone_number parameter. I would suggest rename the variable to plural (phone_numbers) as it is an array, can be accept more than 1 object
 
11:04 AM
@YongShun - I'm Sorry for this question. I'm a bit confused about making is_primary_contact_number and phone_type_id as phone_number. Also will I still have an attribute as phone_number. Because that exists: phone_number, is_primary_contact_number and phone_type_id
 
Okay let me explain to your the structure for the input that need in your back-end
First layer IEmployee

export interface IEmployee {
id?: number;
current_residential_address?: string;
employeephones?: IContact[];
}

To update employee, the model need to have id and current_residential_address
While 1 employee can have more than 1 phone number
In phone number object (IContact), will have phone_number, is_primary_contact_number and phone_type_id attributes
The IContact object you understand right?
So the next thing is employee may have more than 1 IContact object
So there is why employeephones with IContact[] type in the IEmployee object
You understand the model design?
 
How do you place screenshot here. I can't see that. I want to show my current form?
Than't my current form @YongShun
 
You read my previous messages, and compare with your form, the model I explained is as your form and the model that to be received by back-end
 
Thanks. I'm grateful
 
The image I edit will let you more understand for IContact[] part. When you understand the structure of the model, you shall know the error in your backend for phone_numbers part
 
 
1 hour later…
12:24 PM
Problem solved @YongShun. I'm very grateful. Thanks
 

« first day  last day (15 days later) »