Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A School hasMany Batches.
- A Batch belongsTo a School.
- A Batch hasMany Students.
- A Student belongsTo a Batch.
- A User hasMany Schools.
- A School belongsTo a User.
- (A User in this system is a person external to the school that goes in
- and provides teaching services to the students on a weekly basis).
- $student->batch->school->user;
- A Student BelongsTo a School.
- A School hasMany Students.
- $student->school->user;
- public function view(User $user, Student $student) {
- // only the user that a student 'belongsTo' can view them
- return $user->id === $student->batch->school->user->id;
- // OR
- return $user->id === $student->school->user->id;
- }
- // Student Model (simplified, obviously)
- $this->belongsTo(School::class);
- $this->belongsTo(Batch::class);
- $this->belongsTo(User::class);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement