Refactor script

This commit is contained in:
furen81
2026-02-07 04:52:11 +07:00
parent 6e681c4ad3
commit c1ef2df512
20 changed files with 1608 additions and 118 deletions

View File

@ -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');
}
}