Skip to content

Commit

Permalink
Merge pull request #11 from ARCANESOFT/patch-slug_separator
Browse files Browse the repository at this point in the history
Updating config file (slug separator)
  • Loading branch information
arcanedev-maroc authored Sep 25, 2016
2 parents fd43b26 + 736ccc8 commit c18c1ec
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=5.6.4",
"arcanedev/gravatar": "~1.0",
"arcanedev/laravel-auth": "~0.13",
"arcanedev/laravel-auth": "~0.14",
"arcanesoft/core": "~1.0"
},
"require-dev": {
Expand Down
30 changes: 16 additions & 14 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,31 @@
| ------------------------------------------------------------------------------------------------
*/
'users' => [
'table' => 'users',
'model' => Arcanesoft\Auth\Models\User::class,
'observer' => Arcanesoft\Auth\Observers\UserObserver::class,
'table' => 'users',
'model' => Arcanesoft\Auth\Models\User::class,
'observer' => Arcanesoft\Auth\Observers\UserObserver::class,
'slug-separator' => '.',
],

'roles' => [
'table' => 'roles',
'model' => Arcanesoft\Auth\Models\Role::class,
'observer' => Arcanesoft\Auth\Observers\RoleObserver::class,
'table' => 'roles',
'model' => Arcanesoft\Auth\Models\Role::class,
'observer' => Arcanesoft\Auth\Observers\RoleObserver::class,
'slug-separator' => '-',
],

'permissions-groups' => [
'table' => 'permissions_groups',
'model' => Arcanesoft\Auth\Models\PermissionsGroup::class,
'observer' => Arcanesoft\Auth\Observers\PermissionsGroupObserver::class,
'table' => 'permissions_groups',
'model' => Arcanesoft\Auth\Models\PermissionsGroup::class,
'observer' => Arcanesoft\Auth\Observers\PermissionsGroupObserver::class,
'slug-separator' => '-',
],

'permissions' => [
'table' => 'permissions',
'model' => Arcanesoft\Auth\Models\Permission::class,
'observer' => Arcanesoft\Auth\Observers\PermissionObserver::class,
'table' => 'permissions',
'model' => Arcanesoft\Auth\Models\Permission::class,
'observer' => Arcanesoft\Auth\Observers\PermissionObserver::class,
'slug-separator' => '.',
],

/* ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -122,6 +126,4 @@
| ------------------------------------------------------------------------------------------------
*/
'use-observers' => true,

'slug-separator' => '.',
];
3 changes: 2 additions & 1 deletion src/Providers/PackagesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Arcanedev\Gravatar\GravatarServiceProvider;
use Arcanedev\LaravelAuth\LaravelAuthServiceProvider;
use Arcanedev\Support\ServiceProvider;
use Illuminate\Support\Arr;

/**
* Class PackagesServiceProvider
Expand Down Expand Up @@ -62,7 +63,7 @@ private function configLaravelAuthPackage()

$config->set('auth.model', $config->get('arcanesoft.auth.users.model', \Arcanesoft\Auth\Models\User::class));
$config->set('auth.table', $config->get('arcanesoft.auth.users.table', 'users'));
$config->set('laravel-auth', array_except($config->get('arcanesoft.auth'), ['route', 'hasher']));
$config->set('laravel-auth', Arr::except($config->get('arcanesoft.auth'), ['route', 'hasher']));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Seeds/Foundation/PermissionTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function getOtherSeeds()
'name' => 'Dashboard - View the dashboard stats',
'description' => 'Allow to view a auth stats.',
'slug' => 'auth.dashboard.stats',
]
],
];
}
}
14 changes: 13 additions & 1 deletion src/Seeds/RolesSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function prepareRoles(array $roles)
$now = Carbon::now();

foreach ($roles as $key => $role) {
$roles[$key]['slug'] = Str::slug($role['name'], config('arcanesoft.auth.slug-separator', '.'));
$roles[$key]['slug'] = $this->slugify($role['name']);
$roles[$key]['is_active'] = isset($role['is_active']) ? $role['is_active'] : true;
$roles[$key]['is_locked'] = isset($role['is_locked']) ? $role['is_locked'] : true;
$roles[$key]['created_at'] = $now;
Expand All @@ -69,4 +69,16 @@ protected function syncAdminRole()
Permission::all()->pluck('id')->toArray()
);
}

/**
* Slugify the value.
*
* @param string $value
*
* @return string
*/
protected function slugify($value)
{
return Str::slug($value, config('arcanesoft.auth.roles.slug-separator', '-'));
}
}

0 comments on commit c18c1ec

Please sign in to comment.