Download the PHP package resultsystems/relationships without Composer
On this page you can find all versions of the php package resultsystems/relationships. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download resultsystems/relationships
More information about resultsystems/relationships
Files in resultsystems/relationships
Package relationships
Short Description Several Relations for Laravel.
License MIT
Informations about the package relationships
Relationships
This package adds two more kind of relationships based on Laravel's original from Has Many Through
- Installation
- Has One Through Several
- Has Many Through Several
- How To Use
Installation
In the require key of composer.json file add the following:
Important: Do not use dev-master
. Instead, use the tagged version, like shown before.
Run the Composer update comand:
or
Has One Through Several
- Similar to Laravel's hasOne
The "has-one-through-several" relationship provides a convenient shortcut for accessing distant relations via an intermediate relation. For example, a Frequency
model might have one Subject
model through the intermediates Skill
and Schedule
model. In this example, you could easily gather subject for a given frequency. Let's look at the tables required to define this relationship:
frequencies
id - integer
schedule_id - integer
date - date
skills
id - integer
teacher_id - integer
subject_id - integer
title - string
schedules
id - integer
group_id - integer
skill_id - integer
name - string
subjects
id - integer
name - string
// model = frequency
// frequency.schedule_id = schedules.id
// schedules.skill_id = skills.id
// skills.subject_id = subjects.id
Has Many Through Several
- Similar to Laravel's hasMany
The "has-many-through-several" relationship provides a convenient shortcut for accessing distant relations via an intermediate relation. For example, a Group
model might have many Teacher
models through the intermediates Schedule
and Skill
model. In this example, you could easily gather all teachers for a given group. Let's look at the tables required to define this relationship:
groups
id - integer
name - string
teachers
id - integer
name - string
schedules
id - integer
group_id - integer
skill_id - integer
name - string
skills
id - integer
teacher_id - integer
subject_id - integer
title - string
// model = group
// groups.id = schedules.group_id
// skills.id = schedules.skill_id
// teachers.id = skills.teacher_id