Welcome Guest, Not a member yet? Register   Sign In
How develop Model and validation
#7

(This post was last modified: 01-15-2020, 01:05 AM by omid_student.)

(01-13-2020, 11:49 AM)jreklund Wrote: This depends on the person codeing it. If you are doing all validation in the Controller, you you need to duplicate it in every Controller. If you are doing it in the Model, you only need to do it ones.

Here's an example how it's done in Codeigniter 4:
https://codeigniter4.github.io/userguide...ating-data
I agree with you
But in model,what to return to controller?
Example:
if (!'/\d+/',$mobile)
return 'invalid';

or

return -1;

What one is correct?

Thanks

(01-13-2020, 08:33 AM)asrofie Wrote: I think bettet create service class for handling logic process. You can use multiple model (example save log history), and also if you want to create REST Api login, you just call this service class. You can prevent duplicating code for login. Read ADR pattern.

Hope this help

Do you mean Hook?

(01-13-2020, 11:49 AM)jreklund Wrote: This depends on the person codeing it. If you are doing all validation in the Controller, you you need to duplicate it in every Controller. If you are doing it in the Model, you only need to do it ones.

Here's an example how it's done in Codeigniter 4:
https://codeigniter4.github.io/userguide...ating-data

I see relate link
It is good way thanks
Reply


Messages In This Thread
RE: How develop Model and validation - by asrofie - 01-13-2020, 08:33 AM
RE: How develop Model and validation - by Mad Ox - 01-14-2020, 05:13 AM
RE: How develop Model and validation - by omid_student - 01-15-2020, 01:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB