Skip to content

Commit

Permalink
updated migrations and getPermissions()
Browse files Browse the repository at this point in the history
  • Loading branch information
kodeine committed Mar 17, 2015
1 parent 0860431 commit 4f6ffd4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Kodeine/Acl/Traits/HasPermission.php
Expand Up @@ -34,11 +34,11 @@ public function permissions()
public function getPermissions()
{
// user permissions overridden from role.
$permissions = $this->getPermissionsInherited();
$permissions = $this->permissions->lists('slug', 'name');

// permissions based on role.
foreach ($this->roles as $role) {
$permissions = $permissions + $role->getPermissions();
$permissions = array_replace_recursive($role->getPermissions(), $permissions);
}

return $permissions;
Expand Down
2 changes: 1 addition & 1 deletion src/Kodeine/Acl/Traits/HasPermissionInheritance.php
Expand Up @@ -18,7 +18,7 @@ public function getPermissionsInherited()
$inherits = $this->permissions->lists('inherit_id', 'name');

foreach ($inherits as $name => $inherit_id) {
if ( ! $inherit_id ) continue;
if ( is_null($inherit_id) ) continue;

// get inherit row from cache else query it.
$inherit = $this->getCacheInherit($inherit_id);
Expand Down
4 changes: 2 additions & 2 deletions src/migrations/2015_02_07_172649_create_permissions_table.php
Expand Up @@ -15,12 +15,12 @@ public function up()
{
Schema::create('permissions', function (Blueprint $table) {
$table->increments('id');
$table->integer('inherit_id')->unsigned()->index();
$table->integer('inherit_id')->unsigned()->nullable()->index();
$table->foreign('inherit_id')->references('id')->on('permissions');
$table->string('name')->index();
$table->string('slug')->index();
$table->text('description')->nullable();
$table->timestamps();
$table->foreign('inherit_id')->references('id')->on('permissions');
});
}

Expand Down

1 comment on commit 4f6ffd4

@Mythos
Copy link

@Mythos Mythos commented on 4f6ffd4 Mar 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kodeine I would suggest that you revert the changes to the migration and create a new one where you alter the table schema. This should fix some problems for guys who are updating....if the migration is published after composer update

Please sign in to comment.