Commit
This commit is contained in:
17
app/User.php
17
app/User.php
@@ -8,6 +8,7 @@ use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject as AuthenticatableUserContract;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, AuthenticatableUserContract
|
||||
{
|
||||
@@ -26,10 +27,13 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['user_name', 'email', 'password', 'active', 'first_name', 'last_name', 'ban', 'ext', 'mobile', 'profile_pic',
|
||||
'phone_number', 'company', 'agent_sign', 'account_type', 'account_status',
|
||||
'assign_group', 'primary_dpt', 'agent_tzone', 'daylight_save', 'limit_access',
|
||||
'directory_listing', 'vacation_mode', 'role', 'internal_note', 'country_code', 'not_accept_ticket', 'is_delete', ];
|
||||
protected $fillable = [
|
||||
'user_name', 'email', 'password', 'active', 'first_name', 'last_name', 'ban', 'ext', 'mobile', 'profile_pic',
|
||||
'phone_number', 'company', 'agent_sign', 'account_type', 'account_status',
|
||||
'assign_group', 'primary_dpt', 'agent_tzone', 'daylight_save', 'limit_access',
|
||||
'directory_listing', 'vacation_mode', 'role', 'internal_note', 'country_code', 'not_accept_ticket', 'is_delete',
|
||||
'dept_id', // <-- bổ sung trường dept_id vào đây
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
@@ -175,6 +179,11 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
{
|
||||
return $this->name();
|
||||
}
|
||||
public function department()
|
||||
{
|
||||
// User.dept_id là foreign key, Department.id là primary key
|
||||
return $this->belongsTo(Department::class, 'dept_id', 'id');
|
||||
}
|
||||
|
||||
public function getFirstNameAttribute($value)
|
||||
{
|
||||
|
Reference in New Issue
Block a user