@@ -5,39 +5,39 @@ |
||
| 5 | 5 | |
| 6 | 6 | class RoleRepository extends BaseRepository |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Init new object. |
|
| 10 | - * |
|
| 11 | - * @param Role $model |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function __construct(Role $model) |
|
| 15 | - { |
|
| 16 | - parent::__construct($model); |
|
| 17 | - } |
|
| 8 | + /** |
|
| 9 | + * Init new object. |
|
| 10 | + * |
|
| 11 | + * @param Role $model |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function __construct(Role $model) |
|
| 15 | + { |
|
| 16 | + parent::__construct($model); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Detach all permissions from the given role. |
|
| 21 | - * |
|
| 22 | - * @param mixed $role |
|
| 23 | - * @return object |
|
| 24 | - */ |
|
| 25 | - public function detachPermissions($role) |
|
| 26 | - { |
|
| 27 | - $role = ! is_int($role) ? $role : $this->find($role); |
|
| 28 | - $role->permissions()->detach(); |
|
| 29 | - } |
|
| 19 | + /** |
|
| 20 | + * Detach all permissions from the given role. |
|
| 21 | + * |
|
| 22 | + * @param mixed $role |
|
| 23 | + * @return object |
|
| 24 | + */ |
|
| 25 | + public function detachPermissions($role) |
|
| 26 | + { |
|
| 27 | + $role = ! is_int($role) ? $role : $this->find($role); |
|
| 28 | + $role->permissions()->detach(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Attach permission ids to the given role. |
|
| 33 | - * |
|
| 34 | - * @param mixed $role |
|
| 35 | - * @param array $permissionIds |
|
| 36 | - * @return object |
|
| 37 | - */ |
|
| 38 | - public function attachPermissions($role, $permissionIds) |
|
| 39 | - { |
|
| 40 | - $role = ! is_int($role) ? $role : $this->find($role); |
|
| 41 | - $role->permissions()->attach($permissionIds); |
|
| 42 | - } |
|
| 31 | + /** |
|
| 32 | + * Attach permission ids to the given role. |
|
| 33 | + * |
|
| 34 | + * @param mixed $role |
|
| 35 | + * @param array $permissionIds |
|
| 36 | + * @return object |
|
| 37 | + */ |
|
| 38 | + public function attachPermissions($role, $permissionIds) |
|
| 39 | + { |
|
| 40 | + $role = ! is_int($role) ? $role : $this->find($role); |
|
| 41 | + $role->permissions()->attach($permissionIds); |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -18,12 +18,12 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Assign default users to admin roles. |
| 20 | 20 | */ |
| 21 | - $adminRoleId = Role::where('name', 'Admin')->select('id')->first()->id;; |
|
| 21 | + $adminRoleId = Role::where('name', 'Admin')->select('id')->first()->id; ; |
|
| 22 | 22 | $adminUserId = AclUser::where('email', '[email protected]')->select('id')->first()->id; |
| 23 | 23 | \DB::table('role_user')->updateOrInsert([ |
| 24 | 24 | 'user_id' => $adminUserId, |
| 25 | 25 | 'role_id' => $adminRoleId, |
| 26 | - ],[]); |
|
| 26 | + ], []); |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Insert the permissions related to roles table. |
@@ -8,80 +8,80 @@ |
||
| 8 | 8 | |
| 9 | 9 | class RolesTableSeeder extends Seeder |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * Run the database seeds. |
|
| 13 | - * |
|
| 14 | - * @return void |
|
| 15 | - */ |
|
| 16 | - public function run() |
|
| 17 | - { |
|
| 18 | - /** |
|
| 19 | - * Assign default users to admin roles. |
|
| 20 | - */ |
|
| 21 | - $adminRoleId = Role::where('name', 'Admin')->select('id')->first()->id;; |
|
| 22 | - $adminUserId = AclUser::where('email', '[email protected]')->select('id')->first()->id; |
|
| 23 | - \DB::table('role_user')->updateOrInsert([ |
|
| 24 | - 'user_id' => $adminUserId, |
|
| 25 | - 'role_id' => $adminRoleId, |
|
| 26 | - ],[]); |
|
| 11 | + /** |
|
| 12 | + * Run the database seeds. |
|
| 13 | + * |
|
| 14 | + * @return void |
|
| 15 | + */ |
|
| 16 | + public function run() |
|
| 17 | + { |
|
| 18 | + /** |
|
| 19 | + * Assign default users to admin roles. |
|
| 20 | + */ |
|
| 21 | + $adminRoleId = Role::where('name', 'Admin')->select('id')->first()->id;; |
|
| 22 | + $adminUserId = AclUser::where('email', '[email protected]')->select('id')->first()->id; |
|
| 23 | + \DB::table('role_user')->updateOrInsert([ |
|
| 24 | + 'user_id' => $adminUserId, |
|
| 25 | + 'role_id' => $adminRoleId, |
|
| 26 | + ],[]); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Insert the permissions related to roles table. |
|
| 30 | - */ |
|
| 31 | - \DB::table('permissions')->insert( |
|
| 32 | - [ |
|
| 33 | - /** |
|
| 34 | - * Roles model permissions. |
|
| 35 | - */ |
|
| 36 | - [ |
|
| 37 | - 'name' => 'index', |
|
| 38 | - 'model' => 'role', |
|
| 39 | - 'created_at' => \DB::raw('NOW()'), |
|
| 40 | - 'updated_at' => \DB::raw('NOW()') |
|
| 41 | - ], |
|
| 42 | - [ |
|
| 43 | - 'name' => 'show', |
|
| 44 | - 'model' => 'role', |
|
| 45 | - 'created_at' => \DB::raw('NOW()'), |
|
| 46 | - 'updated_at' => \DB::raw('NOW()') |
|
| 47 | - ], |
|
| 48 | - [ |
|
| 49 | - 'name' => 'store', |
|
| 50 | - 'model' => 'role', |
|
| 51 | - 'created_at' => \DB::raw('NOW()'), |
|
| 52 | - 'updated_at' => \DB::raw('NOW()') |
|
| 53 | - ], |
|
| 54 | - [ |
|
| 55 | - 'name' => 'update', |
|
| 56 | - 'model' => 'role', |
|
| 57 | - 'created_at' => \DB::raw('NOW()'), |
|
| 58 | - 'updated_at' => \DB::raw('NOW()') |
|
| 59 | - ], |
|
| 60 | - [ |
|
| 61 | - 'name' => 'destroy', |
|
| 62 | - 'model' => 'role', |
|
| 63 | - 'created_at' => \DB::raw('NOW()'), |
|
| 64 | - 'updated_at' => \DB::raw('NOW()') |
|
| 65 | - ], |
|
| 66 | - [ |
|
| 67 | - 'name' => 'deleted', |
|
| 68 | - 'model' => 'role', |
|
| 69 | - 'created_at' => \DB::raw('NOW()'), |
|
| 70 | - 'updated_at' => \DB::raw('NOW()') |
|
| 71 | - ], |
|
| 72 | - [ |
|
| 73 | - 'name' => 'restore', |
|
| 74 | - 'model' => 'role', |
|
| 75 | - 'created_at' => \DB::raw('NOW()'), |
|
| 76 | - 'updated_at' => \DB::raw('NOW()') |
|
| 77 | - ], |
|
| 78 | - [ |
|
| 79 | - 'name' => 'assignPermissions', |
|
| 80 | - 'model' => 'role', |
|
| 81 | - 'created_at' => \DB::raw('NOW()'), |
|
| 82 | - 'updated_at' => \DB::raw('NOW()') |
|
| 83 | - ], |
|
| 84 | - ] |
|
| 85 | - ); |
|
| 86 | - } |
|
| 28 | + /** |
|
| 29 | + * Insert the permissions related to roles table. |
|
| 30 | + */ |
|
| 31 | + \DB::table('permissions')->insert( |
|
| 32 | + [ |
|
| 33 | + /** |
|
| 34 | + * Roles model permissions. |
|
| 35 | + */ |
|
| 36 | + [ |
|
| 37 | + 'name' => 'index', |
|
| 38 | + 'model' => 'role', |
|
| 39 | + 'created_at' => \DB::raw('NOW()'), |
|
| 40 | + 'updated_at' => \DB::raw('NOW()') |
|
| 41 | + ], |
|
| 42 | + [ |
|
| 43 | + 'name' => 'show', |
|
| 44 | + 'model' => 'role', |
|
| 45 | + 'created_at' => \DB::raw('NOW()'), |
|
| 46 | + 'updated_at' => \DB::raw('NOW()') |
|
| 47 | + ], |
|
| 48 | + [ |
|
| 49 | + 'name' => 'store', |
|
| 50 | + 'model' => 'role', |
|
| 51 | + 'created_at' => \DB::raw('NOW()'), |
|
| 52 | + 'updated_at' => \DB::raw('NOW()') |
|
| 53 | + ], |
|
| 54 | + [ |
|
| 55 | + 'name' => 'update', |
|
| 56 | + 'model' => 'role', |
|
| 57 | + 'created_at' => \DB::raw('NOW()'), |
|
| 58 | + 'updated_at' => \DB::raw('NOW()') |
|
| 59 | + ], |
|
| 60 | + [ |
|
| 61 | + 'name' => 'destroy', |
|
| 62 | + 'model' => 'role', |
|
| 63 | + 'created_at' => \DB::raw('NOW()'), |
|
| 64 | + 'updated_at' => \DB::raw('NOW()') |
|
| 65 | + ], |
|
| 66 | + [ |
|
| 67 | + 'name' => 'deleted', |
|
| 68 | + 'model' => 'role', |
|
| 69 | + 'created_at' => \DB::raw('NOW()'), |
|
| 70 | + 'updated_at' => \DB::raw('NOW()') |
|
| 71 | + ], |
|
| 72 | + [ |
|
| 73 | + 'name' => 'restore', |
|
| 74 | + 'model' => 'role', |
|
| 75 | + 'created_at' => \DB::raw('NOW()'), |
|
| 76 | + 'updated_at' => \DB::raw('NOW()') |
|
| 77 | + ], |
|
| 78 | + [ |
|
| 79 | + 'name' => 'assignPermissions', |
|
| 80 | + 'model' => 'role', |
|
| 81 | + 'created_at' => \DB::raw('NOW()'), |
|
| 82 | + 'updated_at' => \DB::raw('NOW()') |
|
| 83 | + ], |
|
| 84 | + ] |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AssignRelationsSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Assign the permissions to the admin role. |
|
| 20 | - */ |
|
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['role'])->each(function ($permission) use ($adminRoleId) { |
|
| 22 | - \DB::table('permission_role')->insert( |
|
| 23 | - [ |
|
| 24 | - 'permission_id' => $permission->id, |
|
| 25 | - 'role_id' => $adminRoleId, |
|
| 26 | - 'created_at' => \DB::raw('NOW()'), |
|
| 27 | - 'updated_at' => \DB::raw('NOW()') |
|
| 28 | - ] |
|
| 29 | - ); |
|
| 30 | - }); |
|
| 31 | - } |
|
| 18 | + /** |
|
| 19 | + * Assign the permissions to the admin role. |
|
| 20 | + */ |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['role'])->each(function ($permission) use ($adminRoleId) { |
|
| 22 | + \DB::table('permission_role')->insert( |
|
| 23 | + [ |
|
| 24 | + 'permission_id' => $permission->id, |
|
| 25 | + 'role_id' => $adminRoleId, |
|
| 26 | + 'created_at' => \DB::raw('NOW()'), |
|
| 27 | + 'updated_at' => \DB::raw('NOW()') |
|
| 28 | + ] |
|
| 29 | + ); |
|
| 30 | + }); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Assign the permissions to the admin role. |
| 20 | 20 | */ |
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['role'])->each(function ($permission) use ($adminRoleId) { |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['role'])->each(function($permission) use ($adminRoleId) { |
|
| 22 | 22 | \DB::table('permission_role')->insert( |
| 23 | 23 | [ |
| 24 | 24 | 'permission_id' => $permission->id, |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ClearDataSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $permissions = \DB::table('permissions')->whereIn('model', ['role']); |
|
| 17 | - \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | - $permissions->delete(); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $permissions = \DB::table('permissions')->whereIn('model', ['role']); |
|
| 17 | + \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | + $permissions->delete(); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('roles', function (Blueprint $table) { |
|
| 15 | + Schema::create('roles', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->string('name', 100)->unique(); |
| 18 | 18 | $table->softDeletes(); |
| 19 | 19 | $table->timestamps(); |
| 20 | 20 | }); |
| 21 | 21 | |
| 22 | - Schema::create('role_user', function (Blueprint $table) { |
|
| 22 | + Schema::create('role_user', function(Blueprint $table) { |
|
| 23 | 23 | $table->increments('id'); |
| 24 | 24 | $table->unsignedInteger('user_id'); |
| 25 | 25 | $table->unsignedInteger('role_id'); |
@@ -5,40 +5,40 @@ |
||
| 5 | 5 | |
| 6 | 6 | class Roles extends Migration |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Run the migrations. |
|
| 10 | - * |
|
| 11 | - * @return void |
|
| 12 | - */ |
|
| 13 | - public function up() |
|
| 14 | - { |
|
| 15 | - Schema::create('roles', function (Blueprint $table) { |
|
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('name', 100)->unique(); |
|
| 18 | - $table->softDeletes(); |
|
| 19 | - $table->timestamps(); |
|
| 20 | - }); |
|
| 8 | + /** |
|
| 9 | + * Run the migrations. |
|
| 10 | + * |
|
| 11 | + * @return void |
|
| 12 | + */ |
|
| 13 | + public function up() |
|
| 14 | + { |
|
| 15 | + Schema::create('roles', function (Blueprint $table) { |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name', 100)->unique(); |
|
| 18 | + $table->softDeletes(); |
|
| 19 | + $table->timestamps(); |
|
| 20 | + }); |
|
| 21 | 21 | |
| 22 | - Schema::create('role_user', function (Blueprint $table) { |
|
| 23 | - $table->increments('id'); |
|
| 24 | - $table->unsignedInteger('user_id'); |
|
| 25 | - $table->unsignedInteger('role_id'); |
|
| 26 | - $table->softDeletes(); |
|
| 27 | - $table->timestamps(); |
|
| 22 | + Schema::create('role_user', function (Blueprint $table) { |
|
| 23 | + $table->increments('id'); |
|
| 24 | + $table->unsignedInteger('user_id'); |
|
| 25 | + $table->unsignedInteger('role_id'); |
|
| 26 | + $table->softDeletes(); |
|
| 27 | + $table->timestamps(); |
|
| 28 | 28 | |
| 29 | - $table->foreign('user_id')->references('id')->on('users'); |
|
| 30 | - $table->foreign('role_id')->references('id')->on('roles'); |
|
| 31 | - }); |
|
| 32 | - } |
|
| 29 | + $table->foreign('user_id')->references('id')->on('users'); |
|
| 30 | + $table->foreign('role_id')->references('id')->on('roles'); |
|
| 31 | + }); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Reverse the migrations. |
|
| 36 | - * |
|
| 37 | - * @return void |
|
| 38 | - */ |
|
| 39 | - public function down() |
|
| 40 | - { |
|
| 41 | - Schema::dropIfExists('role_user'); |
|
| 42 | - Schema::dropIfExists('roles'); |
|
| 43 | - } |
|
| 34 | + /** |
|
| 35 | + * Reverse the migrations. |
|
| 36 | + * |
|
| 37 | + * @return void |
|
| 38 | + */ |
|
| 39 | + public function down() |
|
| 40 | + { |
|
| 41 | + Schema::dropIfExists('role_user'); |
|
| 42 | + Schema::dropIfExists('roles'); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -5,14 +5,14 @@ |
||
| 5 | 5 | |
| 6 | 6 | class SettingRepository extends BaseRepository |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Init new object. |
|
| 10 | - * |
|
| 11 | - * @param Setting $model |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function __construct(Setting $model) |
|
| 15 | - { |
|
| 16 | - parent::__construct($model); |
|
| 17 | - } |
|
| 8 | + /** |
|
| 9 | + * Init new object. |
|
| 10 | + * |
|
| 11 | + * @param Setting $model |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function __construct(Setting $model) |
|
| 15 | + { |
|
| 16 | + parent::__construct($model); |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AssignRelationsSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Assign the permissions to the admin role. |
|
| 20 | - */ |
|
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['DummyModelName'])->each(function ($permission) use ($adminRoleId) { |
|
| 22 | - \DB::table('permission_role')->insert( |
|
| 23 | - [ |
|
| 24 | - 'permission_id' => $permission->id, |
|
| 25 | - 'role_id' => $adminRoleId, |
|
| 26 | - 'created_at' => \DB::raw('NOW()'), |
|
| 27 | - 'updated_at' => \DB::raw('NOW()') |
|
| 28 | - ] |
|
| 29 | - ); |
|
| 30 | - }); |
|
| 31 | - } |
|
| 18 | + /** |
|
| 19 | + * Assign the permissions to the admin role. |
|
| 20 | + */ |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['DummyModelName'])->each(function ($permission) use ($adminRoleId) { |
|
| 22 | + \DB::table('permission_role')->insert( |
|
| 23 | + [ |
|
| 24 | + 'permission_id' => $permission->id, |
|
| 25 | + 'role_id' => $adminRoleId, |
|
| 26 | + 'created_at' => \DB::raw('NOW()'), |
|
| 27 | + 'updated_at' => \DB::raw('NOW()') |
|
| 28 | + ] |
|
| 29 | + ); |
|
| 30 | + }); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Assign the permissions to the admin role. |
| 20 | 20 | */ |
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['DummyModelName'])->each(function ($permission) use ($adminRoleId) { |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['DummyModelName'])->each(function($permission) use ($adminRoleId) { |
|
| 22 | 22 | \DB::table('permission_role')->insert( |
| 23 | 23 | [ |
| 24 | 24 | 'permission_id' => $permission->id, |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ClearDataSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $permissions = \DB::table('permissions')->whereIn('model', ['DummyModelName']); |
|
| 17 | - \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | - $permissions->delete(); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $permissions = \DB::table('permissions')->whereIn('model', ['DummyModelName']); |
|
| 17 | + \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | + $permissions->delete(); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AssignRelationsSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Assign the permissions to the admin role. |
|
| 20 | - */ |
|
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['setting'])->each(function ($permission) use ($adminRoleId) { |
|
| 22 | - \DB::table('permission_role')->insert( |
|
| 23 | - [ |
|
| 24 | - 'permission_id' => $permission->id, |
|
| 25 | - 'role_id' => $adminRoleId, |
|
| 26 | - 'created_at' => \DB::raw('NOW()'), |
|
| 27 | - 'updated_at' => \DB::raw('NOW()') |
|
| 28 | - ] |
|
| 29 | - ); |
|
| 30 | - }); |
|
| 31 | - } |
|
| 18 | + /** |
|
| 19 | + * Assign the permissions to the admin role. |
|
| 20 | + */ |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['setting'])->each(function ($permission) use ($adminRoleId) { |
|
| 22 | + \DB::table('permission_role')->insert( |
|
| 23 | + [ |
|
| 24 | + 'permission_id' => $permission->id, |
|
| 25 | + 'role_id' => $adminRoleId, |
|
| 26 | + 'created_at' => \DB::raw('NOW()'), |
|
| 27 | + 'updated_at' => \DB::raw('NOW()') |
|
| 28 | + ] |
|
| 29 | + ); |
|
| 30 | + }); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Assign the permissions to the admin role. |
| 20 | 20 | */ |
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['setting'])->each(function ($permission) use ($adminRoleId) { |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['setting'])->each(function($permission) use ($adminRoleId) { |
|
| 22 | 22 | \DB::table('permission_role')->insert( |
| 23 | 23 | [ |
| 24 | 24 | 'permission_id' => $permission->id, |