Complete Task 5

This commit is contained in:
Thuan Bui
2025-04-04 21:43:07 +09:00
parent 0a7a4ab3b4
commit 3a95847a8b
4 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -14,6 +14,6 @@ class Role extends Model
public function users() public function users()
{ {
// TASK: fix this by adding a parameter // TASK: fix this by adding a parameter
return $this->belongsToMany(User::class); return $this->belongsToMany(User::class,'users_roles');
} }
} }
+1 -1
View File
@@ -13,6 +13,6 @@ class Task extends Model
public function user() public function user()
{ {
return $this->belongsTo(User::class, 'users_id'); return $this->belongsTo(User::class, 'users_id')->withDefault();;
} }
} }
+1 -1
View File
@@ -14,7 +14,7 @@ class Team extends Model
public function users() public function users()
{ {
// TASK: fix this by adding some extra code // TASK: fix this by adding some extra code
return $this->belongsToMany(User::class); return $this->belongsToMany(User::class,'team_user')->withPivot('position', 'created_at');
} }
} }
+1
View File
@@ -51,6 +51,7 @@ class User extends Authenticatable
public function comments() public function comments()
{ {
// TASK: add the code here for two-level relationship // TASK: add the code here for two-level relationship
return $this->hasManyThrough(Comment::class, Task::class,'users_id');
} }
public function projects() public function projects()