diff --git a/app/Http/Controllers/Auth/Roles.php b/app/Http/Controllers/Auth/Roles.php index d8d08c4c2..22152f3fc 100644 --- a/app/Http/Controllers/Auth/Roles.php +++ b/app/Http/Controllers/Auth/Roles.php @@ -32,9 +32,9 @@ class Roles extends Controller public function create() { $names = $permissions = []; - $allPermissions = Permission::all(); + $all_permissions = Permission::all(); - foreach ($allPermissions as $permission) { + foreach ($all_permissions as $permission) { // permission code explode - and get permission type $n = explode('-', $permission->name); @@ -85,13 +85,10 @@ class Roles extends Controller */ public function edit(Role $role) { - //$permissions = Permission::all()->sortBy('display_name'); $names = $permissions = []; - $allPermissions = Permission::all(); + $all_permissions = Permission::all(); - $rolePermissions = $role->permissions->pluck('id', 'id')->toArray(); - - foreach ($allPermissions as $permission) { + foreach ($all_permissions as $permission) { // permission code explode - and get permission type $n = explode('-', $permission->name); @@ -102,7 +99,7 @@ class Roles extends Controller $permissions[$n[0]][] = $permission; } - return view('auth.roles.edit', compact('role', 'names', 'permissions', 'rolePermissions')); + return view('auth.roles.edit', compact('role', 'names', 'permissions')); } /** diff --git a/app/Models/Auth/Permission.php b/app/Models/Auth/Permission.php index 451db19f2..b7587911f 100644 --- a/app/Models/Auth/Permission.php +++ b/app/Models/Auth/Permission.php @@ -13,6 +13,13 @@ class Permission extends LaratrustPermission protected $table = 'permissions'; + /** + * The accessors to append to the model's array form. + * + * @var array + */ + protected $appends = ['title']; + /** * The attributes that are mass assignable. * @@ -37,4 +44,24 @@ class Permission extends LaratrustPermission return $query->usingSearchString($search)->sortable($sort)->paginate($limit); } + + /** + * Get the name including rate. + * + * @return string + */ + public function getTitleAttribute() + { + $replaces = [ + 'Create ' => '', + 'Read ' => '', + 'Update ' => '', + 'Delete ' => '', + 'Modules' => 'Apps', + ]; + + $title = str_replace(array_keys($replaces), array_values($replaces), $this->display_name); + + return $title; + } } diff --git a/app/Models/Setting/Tax.php b/app/Models/Setting/Tax.php index 63ff17a1d..39a26cb95 100644 --- a/app/Models/Setting/Tax.php +++ b/app/Models/Setting/Tax.php @@ -6,7 +6,6 @@ use App\Abstracts\Model; class Tax extends Model { - protected $table = 'taxes'; /** diff --git a/resources/views/auth/roles/create.blade.php b/resources/views/auth/roles/create.blade.php index b32b5797c..65bf06bf4 100644 --- a/resources/views/auth/roles/create.blade.php +++ b/resources/views/auth/roles/create.blade.php @@ -34,8 +34,9 @@