diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index a9060e47fd..66abc53e24 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -4,6 +4,7 @@ use App\Http\Middleware\PermissionsRequired; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Auth; +use Utils; class BaseController extends Controller { @@ -34,7 +35,7 @@ class BaseController extends Controller $this->authorize('create', $this->entity); } else{ - $className = ucwords($this->entity, '_'); + $className = Utils::getEntityName($this->entity); $object = call_user_func(array("App\\Models\\{$className}", 'scope'), $input['public_id'])->firstOrFail(); $this->authorize('edit', $object); diff --git a/app/Policies/GenericEntityPolicy.php b/app/Policies/GenericEntityPolicy.php index dab0aab1bc..ad0e76a6ba 100644 --- a/app/Policies/GenericEntityPolicy.php +++ b/app/Policies/GenericEntityPolicy.php @@ -3,6 +3,7 @@ namespace App\Policies; use App\Models\User; +use Utils; use Illuminate\Auth\Access\HandlesAuthorization; @@ -11,7 +12,7 @@ class GenericEntityPolicy use HandlesAuthorization; public static function editByOwner($user, $itemType, $ownerUserId) { - $itemType = ucwords($itemType, '_'); + $itemType = Utils::getEntityName($itemType); if (method_exists("App\\Policies\\{$itemType}Policy", 'editByOwner')) { return call_user_func(array("App\\Policies\\{$itemType}Policy", 'editByOwner'), $user, $ownerUserId); } @@ -20,7 +21,7 @@ class GenericEntityPolicy } public static function viewByOwner($user, $itemType, $ownerUserId) { - $itemType = ucwords($itemType, '_'); + $itemType = Utils::getEntityName($itemType); if (method_exists("App\\Policies\\{$itemType}Policy", 'viewByOwner')) { return call_user_func(array("App\\Policies\\{$itemType}Policy", 'viewByOwner'), $user, $ownerUserId); } @@ -29,7 +30,7 @@ class GenericEntityPolicy } public static function create($user, $itemType) { - $itemType = ucwords($itemType, '_'); + $itemType = Utils::getEntityName($itemType); if (method_exists("App\\Policies\\{$itemType}Policy", 'create')) { return call_user_func(array("App\\Policies\\{$itemType}Policy", 'create'), $user); }