3
3
namespace Kodeine \Acl \Traits ;
4
4
5
5
use Kodeine \Acl \Traits \HasPermission ;
6
+ use Illuminat \Support \Str ;
7
+
6
8
/**
7
9
* Class HasRoleImplementation
8
10
* @package Kodeine\Acl\Traits
9
11
*
10
12
* @method static Builder|Collection|\Eloquent role($role, $column = null)
11
13
*/
12
- trait HasRoleImplementation
14
+ trait HasRole
13
15
{
14
16
use HasPermission;
15
17
@@ -266,13 +268,13 @@ protected function parseRoleId($role)
266
268
public function __call ($ method , $ arguments )
267
269
{
268
270
// Handle isRoleSlug() methods
269
- if ( starts_with ($ method , 'is ' ) and $ method !== 'is ' and ! starts_with ($ method , 'isWith ' ) ) {
271
+ if ( str:: startsWith ($ method , 'is ' ) and $ method !== 'is ' and ! str:: startsWith ($ method , 'isWith ' ) ) {
270
272
$ role = substr ($ method , 2 );
271
273
return $ this ->hasRole ($ role );
272
274
}
273
275
274
276
// Handle canDoSomething() methods
275
- if ( starts_with ($ method , 'can ' ) and $ method !== 'can ' and ! starts_with ($ method , 'canWith ' ) ) {
277
+ if ( str:: startsWith ($ method , 'can ' ) and $ method !== 'can ' and ! str:: startsWith ($ method , 'canWith ' ) ) {
276
278
$ permission = substr ($ method , 3 );
277
279
$ permission = snake_case ($ permission , '. ' );
278
280
@@ -282,18 +284,3 @@ public function __call($method, $arguments)
282
284
return parent ::__call ($ method , $ arguments );
283
285
}
284
286
}
285
-
286
- $ laravel = app ();
287
- if ($ laravel instanceof \Illuminate \Foundation \Application && version_compare ($ laravel ::VERSION , '5.3 ' , '< ' )) {
288
- trait HasRole
289
- {
290
- use HasRoleImplementation {
291
- hasRole as is;
292
- }
293
- }
294
- } else {
295
- trait HasRole
296
- {
297
- use HasRoleImplementation;
298
- }
299
- }
0 commit comments