PHP MVC Object Orientation

Asked

Viewed 349 times

0

I have 4 tables in the database:
Admin - Teacher - Class - Student
and my doubt is :

I would have to create:

Adminmodel.class.php
Professormodel.class.php
Turmamodel.class.php
Alunomodel.class.php

Adminview.class.php
Professorview.class.php
Turmaview.class.php
Alunoview.class.php

Admincontroller.class.php
Professorcontroller.class.php
Turmacontroller.class.php
Alunocontroller.class.php

1 answer

3

Yes, how I answered here.

In your case, all of these are independent, there is no relationship between them.

Teacher is a feature, as well as student, and admin.
Class is a context.

  • The Teacher can be a student, as well as an admin, so he must have these attributes.
  • The student alone can only be admin (can occur, will depend on your case).
  • The Class has teacher, and students, so must have these attributes.
  • Admin adds nothing but control, so no relationship.

Concluding

None of these classes are extends, unless you create Pessoa, ai yes Teacher and student will inherit Person.

  • So from what I understand, whenever I have a unique feature I will have one (Controller, Model and a View) for it. Like if I had "Products" and "Services" I would have to create one for each?

  • Exactly, except maybe there is no need for a view if it is an aggregation or composition.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.