Skip to content

Commit

Permalink
update User.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosun18 committed Feb 2, 2024
1 parent 9e5329e commit 1e27469
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class User extends Authenticatable
{
Expand Down Expand Up @@ -43,4 +45,28 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
'password' => 'hashed',
];

/**
* Get the tasks created by the user.
*/
public function tasks(): HasMany
{
return $this->hasMany(Task::class, 'created_by_id');
}

/**
* Get the tasks assigned to the user.
*/
public function assignedTasks(): HasMany
{
return $this->hasMany(Task::class, 'assigned_to_id');
}

/**
* Get the labels assigned to the user.
*/
public function labels(): BelongsToMany
{
return $this->belongsToMany(Label::class, 'label_user', 'user_id', 'label_id');
}
}

0 comments on commit 1e27469

Please sign in to comment.