Polymorphism

You must clone the III-06-before_polymorphism branch from AnyBlok/anyblok-book-examples repo before starting:

git clone https://github.com/AnyBlok/anyblok-book-examples -b III-06-before_polymorphisme III-06-polymorphisme
cd III-06-polymorphisme

We have added some models to get started with polymorphism:

  • A person blok that contains following models
    • Person model that represents people with a name and firstname
    • Employee model that adds position field on person model using polymorphism
  • A university blok that represents all things regarding education
    • Professor model that extends Employee model using polymorphism
    • Student model that extends Person model using polymorphism

We also add the University model link to the Address model, an university could have zero or more addresses.

Polymorphism in AnyBlok allows you to get clear business readable queries as we will see later.

...

results matching ""

    No results matching ""