mirror of
https://github.com/10h30/Test-Eloquent-Relationships.git
synced 2026-07-11 10:46:13 +09:00
Complete Task 5
This commit is contained in:
+1
-1
@@ -14,6 +14,6 @@ class Role extends Model
|
||||
public function users()
|
||||
{
|
||||
// TASK: fix this by adding a parameter
|
||||
return $this->belongsToMany(User::class);
|
||||
return $this->belongsToMany(User::class,'users_roles');
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,6 +13,6 @@ class Task extends Model
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'users_id');
|
||||
return $this->belongsTo(User::class, 'users_id')->withDefault();;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ class Team extends Model
|
||||
public function users()
|
||||
{
|
||||
// TASK: fix this by adding some extra code
|
||||
return $this->belongsToMany(User::class);
|
||||
return $this->belongsToMany(User::class,'team_user')->withPivot('position', 'created_at');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ class User extends Authenticatable
|
||||
public function comments()
|
||||
{
|
||||
// TASK: add the code here for two-level relationship
|
||||
return $this->hasManyThrough(Comment::class, Task::class,'users_id');
|
||||
}
|
||||
|
||||
public function projects()
|
||||
|
||||
Reference in New Issue
Block a user