33namespace Kodeine \Acl \Traits ;
44
55use Kodeine \Acl \Traits \HasPermission ;
6+ use Illuminat \Support \Str ;
7+
68/**
79 * Class HasRoleImplementation
810 * @package Kodeine\Acl\Traits
911 *
1012 * @method static Builder|Collection|\Eloquent role($role, $column = null)
1113 */
12- trait HasRoleImplementation
14+ trait HasRole
1315{
1416 use HasPermission;
1517
@@ -266,13 +268,13 @@ protected function parseRoleId($role)
266268 public function __call ($ method , $ arguments )
267269 {
268270 // 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 ' ) ) {
270272 $ role = substr ($ method , 2 );
271273 return $ this ->hasRole ($ role );
272274 }
273275
274276 // 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 ' ) ) {
276278 $ permission = substr ($ method , 3 );
277279 $ permission = snake_case ($ permission , '. ' );
278280
@@ -282,18 +284,3 @@ public function __call($method, $arguments)
282284 return parent ::__call ($ method , $ arguments );
283285 }
284286}
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