Skip to content

Commit

Permalink
update helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
httpoz committed Nov 1, 2019
1 parent 93a5ee2 commit d749ace
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
*/

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use Illuminate\Support\Str;

$factory->define( \HttpOz\Roles\Tests\Stubs\User::class, function ( Faker\Generator $faker ) {
static $password;

return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt( 'secret' ),
'remember_token' => str_random( 10 ),
'remember_token' => Str::random( 10 ),
];
} );

Expand Down
4 changes: 2 additions & 2 deletions src/Traits/HasRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ private function getArrayFrom( $argument ) {
* @return mixed
*/
public function __call( $method, $parameters ) {
if ( starts_with( $method, 'is' ) ) {
return $this->isRole( snake_case( substr( $method, 2 ), config( 'roles.separator' ) ) );
if ( Str::startsWith( $method, 'is' ) ) {
return $this->isRole( Str::snake( substr( $method, 2 ), config( 'roles.separator' ) ) );
}

return parent::__call( $method, $parameters );
Expand Down
6 changes: 4 additions & 2 deletions src/Traits/Sluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace HttpOz\Roles\Traits;

use Illuminate\Support\Str;

trait Sluggable
{
/**
Expand All @@ -13,12 +15,12 @@ trait Sluggable

public function setSlugAttribute($value)
{
$this->attributes['slug'] = str_slug($value, config('roles.separator'));
$this->attributes['slug'] = Str::slug($value, config('roles.separator'));
}

public function setGroupAttribute($value)
{
$this->attributes['group'] = str_slug($value, config('roles.separator'));
$this->attributes['group'] = Str::slug($value, config('roles.separator'));
}

}

0 comments on commit d749ace

Please sign in to comment.