[WIP] Fix ergonomics rules
This commit is contained in:
45
app/Models/Core/Auth/Role.php
Normal file
45
app/Models/Core/Auth/Role.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Laratrust\Models\LaratrustRole;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $display_name
|
||||
* @property string $description
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Permission[] $permissions
|
||||
*
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereDisplayName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
|
||||
class Role extends LaratrustRole
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function getDisplayNameAttribute($value)
|
||||
{
|
||||
return __($value);
|
||||
}
|
||||
|
||||
public function getDescriptionAttribute($value)
|
||||
{
|
||||
return __($value);
|
||||
}
|
||||
|
||||
public function getNbUsers()
|
||||
{
|
||||
return User::whereRoleIs($this->name)->count();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user