Роли, переделывание отчета, изменение на главной странице
This commit is contained in:
37
app/Models/Role.php
Normal file
37
app/Models/Role.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $primaryKey = 'role_id';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
public function userRoles(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserRole::class, 'rf_role_id', 'role_id');
|
||||
}
|
||||
|
||||
public function users(): HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
User::class,
|
||||
UserRole::class,
|
||||
'rf_role_id',
|
||||
'id',
|
||||
'role_id',
|
||||
'rf_user_id'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user