Quantcast

How To / Example of OO Inheritance for CakePHP 3

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How To / Example of OO Inheritance for CakePHP 3

Willem

how would one create a CakePHP3 app and what database tabels would i need to create an app that uses inheritance.

for example fictional setup:

[Person] <--- [Customer]
[Person]<--- [Manager]

All Persons have "name". Customer has "order_amount". Manager has "sales_total". 

Person has a method "getName()" , which is avavailable through inheritance in Customer and manager.

Person is the parent class and Customer and manager are the child-classes.

How would i implement this in CakePHP?

I could create a customer and manager database table and bake this to two models. but that would mean that the getName() function would be implemented in both classes. 

Could somebody help me grasp this in cakephp? thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How To / Example of OO Inheritance for CakePHP 3

Florian Krämer-2
Do the official Tutorials, they'll teach you how to work with CakePHP.

http://book.cakephp.org/3.0/en/tutorials-and-examples.html

The level of abstraction in CakePHP is higher than what you describe, you don't implement these methods on model or table objects, entities represent data. They represent data objects and you can implement accessors and mutators to implement more specific behavior than a simple getter and setter. I highly recommend you to read the documentation.

On Monday, January 25, 2016 at 4:50:52 PM UTC+1, Willem wrote:

how would one create a CakePHP3 app and what database tabels would i need to create an app that uses inheritance.

for example fictional setup:

[Person] <--- [Customer]
[Person]<--- [Manager]

All Persons have "name". Customer has "order_amount". Manager has "sales_total". 

Person has a method "getName()" , which is avavailable through inheritance in Customer and manager.

Person is the parent class and Customer and manager are the child-classes.

How would i implement this in CakePHP?

I could create a customer and manager database table and bake this to two models. but that would mean that the getName() function would be implemented in both classes. 

Could somebody help me grasp this in cakephp? thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How To / Example of OO Inheritance for CakePHP 3

Willem
In reply to this post by Willem
I have done the tutorials. I posted because it is not totally clear. Reading the docs has let me to believe there should be a model for every database table. but if i would do that i would end up with a model for Customer and a model for Manager both containing the , more or less, same fields and the same method. That seems strange to me and that is why i posted the question. Sometimes things just get more clear with a simple example. 


so to rephrase: if somebody would come to you with this specific UML how would you create this setup using CakePHP. 

tx



On Monday, January 25, 2016 at 4:50:52 PM UTC+1, Willem wrote:

how would one create a CakePHP3 app and what database tabels would i need to create an app that uses inheritance.

for example fictional setup:

[Person] <--- [Customer]
[Person]<--- [Manager]

All Persons have "name". Customer has "order_amount". Manager has "sales_total". 

Person has a method "getName()" , which is avavailable through inheritance in Customer and manager.

Person is the parent class and Customer and manager are the child-classes.

How would i implement this in CakePHP?

I could create a customer and manager database table and bake this to two models. but that would mean that the getName() function would be implemented in both classes. 

Could somebody help me grasp this in cakephp? thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Loading...