OldNurse
OldNurse

Reputation: 153

Keep my model methods and bake models again

I really like how CakePHP's Bakery bakes all models for me and takes care of validation and its relations.

The problem is when I have my models already generated and then I add some custom methods to my models. Everytime I add more tables to database, I'd like to bake my models and its relations again.

Is there any way to keep my methods and variables like $actsAs untouched and regenerate the whole model structure without any harm to my custom code?

Upvotes: 1

Views: 70

Answers (2)

floriank
floriank

Reputation: 25698

No, it's not possible. But technically it would be possible to add this feature to the bake shell, you're welcome to implement it! Using reflections and some preg_replace should do it.

Another solution would be to write a bash script using git, that does a diff and then does a merge more or less automatically for you.

However, I don't understand your issue, adding additional associations is not really hard and complicated work.

Upvotes: 3

Abhishek
Abhishek

Reputation: 805

You can bake each model separately using

cake bake Model User

You can replace User to any model as you need

Upvotes: 0

Related Questions