1

I am trying to build a simple Laravel application. My data model looks like the following:

ENTITIES: 
Project, Requirements, ProjectRequirementStatus

RELATIONSHIPS:
A Project has many Requirements
A requirement belongs to many Projects as a "ProjectRequirement"
A "ProjectRequirement" has one ProjectRequirementStatus
A ProjectRequirementStatus belongs to many Projects

TABLES:
projects
requirements
project_requirements
project_requirement_statuses

MODELS:
Project, Requirements, ProjectRequirementStatus

My question IS:

Is it improper to create a model for a relationship class? In this case, I would need to create a ProjectRequirement model and define the relationship to the ProjectRequirementStatus class.

I'm confused because most of my pivot tables include IDs of the two tables they are joining in a Many to Many, and typically, no additional relationships.

Am I thinking about this the wrong way? Are there "best practices" in terms of when a Model is created versus when it's not needed?

tereško
  • 58,060
  • 25
  • 98
  • 150
Neurax
  • 3,657
  • 2
  • 13
  • 18

1 Answers1

0

Using the 3NF in Laravel, you do not have to make models for the relationships. Laravel provides the Eloquent ORM which will provide the relationships without having to make the pivot tables models.

The Eloquent ORM also provides you a way to access data on pivot tables. (Defining The Inverse Of The Relationship)

Elisha Senoo
  • 3,489
  • 2
  • 22
  • 29