#118 - keys
This commit is contained in:
@@ -11,8 +11,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property User $owner
|
||||
* @property User $previousOwner
|
||||
* @property User $user
|
||||
*/
|
||||
class Key extends Model
|
||||
{
|
||||
@@ -20,14 +19,9 @@ class Key extends Model
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function owner(): BelongsTo
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, "owner_id");
|
||||
}
|
||||
|
||||
public function previousOwner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, "previous_owner_id");
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
protected static function newFactory(): KeyFactory
|
||||
|
@@ -74,6 +74,11 @@ class User extends Authenticatable
|
||||
return $this->hasMany(Vacation::class);
|
||||
}
|
||||
|
||||
public function keys(): HasMany
|
||||
{
|
||||
return $this->hasMany(Key::class);
|
||||
}
|
||||
|
||||
public function hasRole(Role $role): bool
|
||||
{
|
||||
return $this->role === $role;
|
||||
|
Reference in New Issue
Block a user