removed prefix from permission title

This commit is contained in:
denisdulici
2020-01-07 23:36:18 +03:00
parent 4c959bc91c
commit 551c27c3d7
5 changed files with 42 additions and 15 deletions

View File

@@ -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;
}
}