Skip to content

Commit

Permalink
Merge branch 'release/1.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mekaeil committed Jul 10, 2019
2 parents 06d5220 + 2ce5489 commit b796420
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 202 deletions.
18 changes: 4 additions & 14 deletions src/Config/laravel_user_management.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,11 @@
* BETWEEN USERS TABLE & USER DEPARTMENTS TABLE
* **/
// laravel_user_management.user_department_user_table
'user_department_user_table' => 'user_departments',
'user_department_user_table' => 'user_departments_users',

// laravel_user_management.user_model
'user_model' => \Mekaeil\LaravelUserManagement\Entities\User::class,
'user_model' => App\Entities\User::class,

// laravel_user_management.fillables_column
'fillables_column' => [
'first_name',
'last_name',
'password',
'email',
'mobile',
'status',
'remember_token',
'mobile_verified',
'email_verified',
],


];
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function up()
$table = config("laravel_user_management.users_table");
Schema::create($table, function (Blueprint $table) {
$table->increments('id');
$this->createTable(config("laravel_user_management.migrations_columns"));
$table->string('first_name');
$table->string('last_name');
$table->string('email')->nullable()->unique();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up()
$users_table = config("laravel_user_management.users_table");
$table = config("laravel_user_management.user_department_user_table");

Schema::create($table, function (Blueprint $table)
Schema::create($table, function (Blueprint $table) use($departments_table,$users_table)
{
$table->unsignedInteger('user_id');
$table->unsignedInteger('department_id');
Expand Down
27 changes: 5 additions & 22 deletions src/Database/Seeders/Permission/MasterPermissionTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ public function run()
'name' => array_keys($rolePermissions)[0],
'guard_name' => $guard
]);
// $permObject = Permission::where('name', array_keys($rolePermissions)[0] )
// ->where('guard_name',$guard)
// ->first();
$permObject->syncRoles( $this->getRolesID($rolePermissions[array_keys($rolePermissions)[0]],$guard) );
}

Expand Down Expand Up @@ -90,7 +87,6 @@ public function run()
{
$this->command->info(' THIS PERMISSION <<' . $perm . ' >> ASSIGNED TO THESE ROLES <<<< '. implode(' - ', $roles) . ' >>> GUARD NAME = ' . $this->guardName);
$permObject = $this->permissionRepository->findBy(['name' => $perm]);
// $permObject = Permission::where('name',$perm)->first();
$permObject->syncRoles( $this->getRolesID($roles,$this->guardName) );
}

Expand All @@ -116,8 +112,6 @@ private function setPermissions(array $permission , $guard = null)
'name' => $permission['name'],
'guard_name'=> $getGuard
]);
// $getPermission = Permission::where('name',$permission['name'])
// ->where('guard_name',$getGuard)->first();

if (! is_null($getPermission))
{
Expand All @@ -130,13 +124,6 @@ private function setPermissions(array $permission , $guard = null)
'module' => isset($permission['module']) ? $permission['module'] : null ,
'description' => isset($permission['description']) ? $permission['description'] : null ,
]);
// $getPermission->update([
// 'name' => $permission['name'],
// 'guard_name' => $guard ?? $permission['guard_name'],
// 'title' => isset($permission['title']) ? $permission['title'] : null ,
// 'module' => isset($permission['module']) ? $permission['module'] : null ,
// 'description' => isset($permission['description']) ? $permission['description'] : null ,
// ]);

$rolePermissions[$permission['name']] = array_values($permission['roles']) ?? null ;

Expand All @@ -153,14 +140,6 @@ private function setPermissions(array $permission , $guard = null)
'description' => isset($permission['description']) ? $permission['description'] : null ,
]);

// Permission::create([
// 'name' => $permission['name'],
// 'guard_name' => $getGuard,
// 'title' => isset($permission['title']) ? $permission['title'] : null ,
// 'module' => isset($permission['module']) ? $permission['module'] : null ,
// 'description' => isset($permission['description']) ? $permission['description'] : null ,
// ]);

$rolePermissions[$permission['name']] = array_values($permission['roles']) ?? null ;

return $rolePermissions;
Expand All @@ -172,7 +151,11 @@ private function getRolesID(array $roles, $guard)
$roleIDs = array();
foreach ($roles as $role)
{
$roleIDs[] = optional(Role::where('name', $role)->where('guard_name', $guard)->first())->id;
$findRole = $this->roleRepository->findBy([
'name' => $role,
'guard_name' => $guard
]);
$roleIDs[] = $findRole ? $findRole->id : null;
}
return array_values($roleIDs);
}
Expand Down
18 changes: 8 additions & 10 deletions src/Database/Seeders/Permission/PermissionTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ class PermissionTableSeeder extends MasterPermissionTableSeeder
{
protected $permissions = [
[
[
'name' => 'admin.manager',
'display_name' => 'مدیریت بخش‌های ادمین',
'guard_name' => 'api',
'description' => 'این دسترسی جهت مشاهده بخش‌های عمومی ادمین ایجاد شده است.',
'module' => 'User',
'roles' => [
'Admin',
],
'name' => 'admin.manager',
'display_name' => 'پنل مدیریت',
'guard_name' => 'web',
'description' => 'این مجوز برای دسترسی کاربر به ادمین می‌باشد.',
'module' => 'User',
'roles' => [
'Admin',
],
]
],
];


Expand Down
21 changes: 8 additions & 13 deletions src/Database/Seeders/Role/MasterRoleTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ public function run()

foreach ($this->getRoles() as $role)
{
$findRole = Role::where('name',$role['name'])
->where('guard_name',$role['guard_name'])
->first();
$findRole = $this->roleRepository->findBy([
'name' => $role['name'],
'guard_name' => $role['guard_name']
]);

if ($findRole)
{
$this->command->info('THIS ROLE << ' . $role['name'] .'['. $role['guard_name'] . '] >> EXISTED! UPDATING DATA ...');


$findRole->update([
$this->roleRepository->update($findRole->id,[
'name' => $role['name'],
'display_name' => $role['display_name'],
'title' => $role['title'],
'guard_name' => $role['guard_name'],
'description' => isset($role['description']) ? $role['description'] : null,
]);
Expand All @@ -58,20 +58,15 @@ public function run()

$this->command->info('CREATING THIS ROLE <<' . $role['name'] .'['. $role['guard_name'] . '] >> ...');

Role::create([
$this->roleRepository->store([
'name' => $role['name'],
'display_name' => $role['display_name'],
'title' => $role['title'],
'guard_name' => $role['guard_name'],
'description' => isset($role['description']) ? $role['description'] : null,
]);

}

Cache::forget('roles');
Cache::rememberForever('roles', function () {
return \DB::table('roles')->get()->pluck('id', 'name')->toArray();
});

$this->command->info("\n");
$this->command->info('=============================================================');
$this->command->info(' INSERTING ROLES FINALIZED!');
Expand Down
8 changes: 4 additions & 4 deletions src/Database/Seeders/Role/RoleTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
use Mekaeil\LaravelUserManagement\seeders\Permission\MasterRoleTableSeeder;
class RoleTableSeeder extends MasterRoleTableSeeder
{
protected $permissions = [
protected $roles = [
[
'name' => "Admin",
'title' => "Administrator",
'guard_name' => "web",
'description' => "This role will assign to project owner",
'description' => "This role will assign to Administrator",
],
[
'name' => "User",
'title' => "Client",
'title' => "User",
'guard_name' => "web",
'description' => "This role will assign to usual users or clients",
'description' => "This role will assign to user.",
],

];
Expand Down
82 changes: 0 additions & 82 deletions src/Database/Seeders/User/MasterUserTableSeeder.php

This file was deleted.

17 changes: 0 additions & 17 deletions src/Database/Seeders/User/UserTableSeeder.php

This file was deleted.

11 changes: 1 addition & 10 deletions src/Database/Seeders/UserManagementDatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ class UserManagementDatabaseSeeder extends Seeder
*/
public function run()
{
Model::unguard();

/*
|--------------------------------------------------------------------------
| PERMISSIONS USER MANAGEMENT
|--------------------------------------------------------------------------
|
*/


Model::unguard();

}
}
2 changes: 1 addition & 1 deletion src/LaravelUserManagementProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function boot()
//// SET MIGRATION'S ROUTE
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');


/// PUBLISH SECTION
////////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down
5 changes: 1 addition & 4 deletions src/Repository/Contracts/DepartmentRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

namespace Mekaeil\LaravelUserManagement\Repository\Contracts;

use Modules\User\Entities\Department;
use Modules\User\Http\Requests\Admin\StoreDepartment;

interface DepartmentRepositoryInterface
interface DepartmentRepositoryInterface extends BaseRepositoryInterface
{

}
3 changes: 1 addition & 2 deletions src/Repository/Contracts/PermissionRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Mekaeil\LaravelUserManagement\Repository\Contracts;


interface PermissionRepositoryInterface extends RepositoryInterface
interface PermissionRepositoryInterface extends BaseRepositoryInterface
{

}
17 changes: 0 additions & 17 deletions src/Repository/Contracts/RepositoryInterface.php

This file was deleted.

3 changes: 1 addition & 2 deletions src/Repository/Contracts/RoleRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Mekaeil\LaravelUserManagement\Repository\Contracts;


interface RoleRepositoryInterface extends RepositoryInterface
interface RoleRepositoryInterface extends BaseRepositoryInterface
{

}
Loading

0 comments on commit b796420

Please sign in to comment.