From f9ae69d0448ea9fc50ab39d728c8ddd6a07fca9c Mon Sep 17 00:00:00 2001 From: Hafijul Islam Date: Fri, 19 Nov 2021 01:44:28 +0600 Subject: [PATCH] helper class issue fixed --- Database/Seeders/Rbac/PermissionSeeder.php | 3 ++- Supports/Utility.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Database/Seeders/Rbac/PermissionSeeder.php b/Database/Seeders/Rbac/PermissionSeeder.php index 76076f2..85e1830 100644 --- a/Database/Seeders/Rbac/PermissionSeeder.php +++ b/Database/Seeders/Rbac/PermissionSeeder.php @@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Route; use Modules\Admin\Models\Rbac\Permission; use Modules\Admin\Supports\Helper; +use Modules\Admin\Supports\Utility; class PermissionSeeder extends Seeder { @@ -26,7 +27,7 @@ public function run() foreach ($routes as $route) { try { - Permission::create(['display_name' => Helper::permissionDisplay($route), 'name' => $route, 'guard_name' => 'web', 'enabled' => 'yes']); + Permission::create(['display_name' => Utility::permissionDisplay($route), 'name' => $route, 'guard_name' => 'web', 'enabled' => 'yes']); } catch (\PDOException $exception) { throw new \PDOException($exception->getMessage()); } diff --git a/Supports/Utility.php b/Supports/Utility.php index a749c02..4f4bf8f 100644 --- a/Supports/Utility.php +++ b/Supports/Utility.php @@ -90,4 +90,15 @@ public static function formatLogFilename(string $filename) return preg_replace('/laravel\-([\d]{4})-([\d]{2})-([\d]{2})\.log/', '$3/$2/$1', $filename); } + + /** + * Convert Route Name Human Readable Style + * + * @param string $permission + * @return string + */ + public static function permissionDisplay(string $permission): string + { + return ucwords(str_replace(['.', '-', '_'], [' ', ' ', ' '], $permission)); + } }