chore
This commit is contained in:
@@ -20,7 +20,6 @@ class RolesController extends Controller
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -29,7 +28,7 @@ class RolesController extends Controller
|
||||
return $this->model->setBeforeGetList(function ($query) {
|
||||
return $query->with(['permissions' => function ($query) {
|
||||
$query->select('id');
|
||||
}])->dataRange();
|
||||
}]);
|
||||
})->getList();
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Permissions\Providers;
|
||||
namespace Modules\Permissions;
|
||||
|
||||
use Catch\Support\Module\Installer as ModuleInstaller;
|
||||
use Modules\Permissions\Providers\PermissionsServiceProvider;
|
||||
|
||||
class Installer extends ModuleInstaller
|
||||
{
|
||||
|
@@ -5,8 +5,8 @@ declare(strict_types=1);
|
||||
namespace Modules\Permissions\Models;
|
||||
|
||||
use Catch\Base\CatchModel as Model;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Modules\Permissions\Models\Traits\DataRange;
|
||||
|
||||
/**
|
||||
* @property $role_name
|
||||
@@ -21,8 +21,6 @@ use Modules\Permissions\Models\Traits\DataRange;
|
||||
*/
|
||||
class Roles extends Model
|
||||
{
|
||||
use DataRange;
|
||||
|
||||
protected $table = 'roles';
|
||||
|
||||
protected $fillable = ['id', 'role_name', 'identify', 'parent_id', 'description', 'data_range', 'creator_id', 'created_at', 'updated_at', 'deleted_at'];
|
||||
@@ -75,4 +73,22 @@ class Roles extends Model
|
||||
{
|
||||
return $this->belongsToMany(Departments::class, 'role_has_departments', 'role_id', 'department_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* get role's permissions
|
||||
* @return Collection
|
||||
*/
|
||||
public function getPermissions(): Collection
|
||||
{
|
||||
return $this->permissions()->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* get role's departments
|
||||
* @return Collection
|
||||
*/
|
||||
public function getDepartments(): Collection
|
||||
{
|
||||
return $this->departments()->get();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user