Refactor script
This commit is contained in:
@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use MongoDB\Laravel\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@ -23,6 +24,8 @@ class User extends Authenticatable
|
||||
'color',
|
||||
'role',
|
||||
'is_active',
|
||||
'agent_id', // [NEW] Link staff to agent
|
||||
'user_group_id', // [NEW] Link to UserGroup (Permissions)
|
||||
];
|
||||
|
||||
/**
|
||||
@ -60,4 +63,20 @@ class User extends Authenticatable
|
||||
{
|
||||
return $this->hasMany(SalesPlan::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the agent that this user belongs to.
|
||||
*/
|
||||
public function agent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Agent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user group (role) of the user
|
||||
*/
|
||||
public function group(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(UserGroup::class, 'user_group_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user