mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
These are roles defined by a special API code, once a system role code is detected, the role becomes locked and its permissions are sourced from the AuthManager. All permissions are granted to system roles by default, unless otherwise specified. This should make it easier to create client accounts as "Publishers", hiding developer tools like the CMS and Builder plugins by default.
47 lines
1015 B
PHP
47 lines
1015 B
PHP
<?php namespace Backend\Models;
|
|
|
|
use October\Rain\Auth\Models\Group as GroupBase;
|
|
|
|
/**
|
|
* Administrator group
|
|
*
|
|
* @package october\backend
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
*/
|
|
class UserGroup extends GroupBase
|
|
{
|
|
const CODE_OWNERS = 'owners';
|
|
|
|
/**
|
|
* @var string The database table used by the model.
|
|
*/
|
|
protected $table = 'backend_user_groups';
|
|
|
|
/**
|
|
* @var array Validation rules
|
|
*/
|
|
public $rules = [
|
|
'name' => 'required|between:2,128|unique:backend_user_groups',
|
|
];
|
|
|
|
/**
|
|
* @var array Relations
|
|
*/
|
|
public $belongsToMany = [
|
|
'users' => [User::class, 'table' => 'backend_users_groups'],
|
|
'users_count' => [User::class, 'table' => 'backend_users_groups', 'count' => true]
|
|
];
|
|
|
|
public function afterCreate()
|
|
{
|
|
if ($this->is_new_user_default) {
|
|
$this->addAllUsersToGroup();
|
|
}
|
|
}
|
|
|
|
public function addAllUsersToGroup()
|
|
{
|
|
$this->users()->sync(User::lists('id'));
|
|
}
|
|
}
|