added user roles relationship
This commit is contained in:
parent
894c2cef1a
commit
61670c1f2d
@ -94,6 +94,11 @@ class User extends Authenticatable implements HasLocalePreference
|
||||
return $this->hasOne('App\Models\Auth\UserInvitation', 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function roles()
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Auth\Role', 'App\Models\Auth\UserRole');
|
||||
}
|
||||
|
||||
/**
|
||||
* Always capitalize the name when we retrieve it
|
||||
*/
|
||||
|
36
app/Models/Auth/UserRole.php
Normal file
36
app/Models/Auth/UserRole.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
|
||||
class UserRole extends Model
|
||||
{
|
||||
protected $table = 'user_roles';
|
||||
|
||||
protected $tenantable = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['user_id', 'role_id', 'user_type'];
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Auth\User');
|
||||
}
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Auth\Role');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user