Skip to content

Commit 41964e8

Browse files
committed
Fixed str_slug and load resources
1 parent 96bd3ad commit 41964e8

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

config/permission.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
return [
4-
'prefix' => 'admin',
5-
'namespace' => '\CodexShaper\Permission',
6-
'controller_namespace' => '\CodexShaper\Permission\Http\Controllers',
4+
'prefix' => 'admin',
5+
'namespace' => '\CodexShaper\Permission',
6+
'controller_namespace' => '\CodexShaper\Permission\Http\Controllers',
77
'models' => [
88
'permission' => CodexShaper\Permission\Models\Permission::class,
99
'role' => CodexShaper\Permission\Models\Role::class,
@@ -14,6 +14,6 @@
1414
'permissions' => 'permissions',
1515
'permission_role' => 'permission_role',
1616
],
17-
'resources_path' => 'package/laravel-permission/resources/assets/',
17+
'resources_path' => 'vendor/codexshaper/laravel-permission/resources/assets/',
1818

1919
];

src/Helpers/helpers.php

+26-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,35 @@
55
*/
66
if( !function_exists('slug') ) {
77
function slug($string) {
8-
return str_slug($string);
9-
}
8+
// replace non letter or digits by -
9+
$string = preg_replace('~[^\pL\d]+~u', '-', $string);
10+
11+
// transliterate
12+
$string = iconv('utf-8', 'us-ascii//TRANSLIT', $string);
13+
14+
// remove unwanted characters
15+
$string = preg_replace('~[^-\w]+~', '', $string);
16+
17+
// trim
18+
$string = trim($string, '-');
19+
20+
// remove duplicate -
21+
$string = preg_replace('~-+~', '-', $string);
22+
23+
// lowercase
24+
$string = strtolower($string);
25+
26+
if (empty($string)) {
27+
return 'n-a';
28+
}
29+
30+
return $string;
31+
}
1032
}
1133
if( !function_exists('str_spliter') ) {
1234
function str_spliter( $str, $pattern = '/[\s,.|]/' ) {
13-
return preg_split( $pattern, $str);
14-
}
35+
return preg_split( $pattern, $str);
36+
}
1537
}
1638
if( !function_exists('permission_asset') ) {
1739
function permission_asset( $path ) {

0 commit comments

Comments
 (0)