Skip to content

Commit

Permalink
Ready to use
Browse files Browse the repository at this point in the history
  • Loading branch information
farhoudi committed Nov 6, 2020
2 parents dba0583 + 9b9d13b commit 4969ac6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/.idea
/vendor
composer.lock
composer.lock
7 changes: 7 additions & 0 deletions src/Models/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Permission extends Model {
'name',
'alias',
'description',
'group_id',
];

/**
Expand All @@ -32,6 +33,7 @@ class Permission extends Model {
'name' => 'string',
'alias' => 'string',
'description' => 'string',
'group_id' => 'integer',
];

/**
Expand All @@ -43,6 +45,7 @@ class Permission extends Model {
'name' => 'required|string',
'alias' => 'nullable|string|unique:rbac_permissions,alias',
'description' => 'nullable|string',
'group_id' => 'nullable|integer|exists:rbac_permission_groups,id',
];

protected $hidden = [
Expand All @@ -55,4 +58,8 @@ public function roles() {
return $this->belongsToMany(Role::class, 'rbac_permission_role', 'permission_id', 'role_id');
}

public function group() {
return $this->belongsTo(PermissionGroup::class, 'group_id', 'role_id');
}

}
2 changes: 1 addition & 1 deletion src/Models/PermissionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Class Permission
* Class PermissionGroup
* @package Farhoudi\Rbac\Models
*/
class PermissionGroup extends Model {
Expand Down
4 changes: 1 addition & 3 deletions src/RbacServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Farhoudi\Rbac;

use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\ServiceProvider;

class RbacServiceProvider extends ServiceProvider {
Expand All @@ -18,4 +16,4 @@ public function boot() {
], 'migrations');
}

}
}
9 changes: 5 additions & 4 deletions src/migrations/2017_11_29_205659_create_rbac_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ public function up() {
* @return void
*/
public function down() {
Schema::drop('rbac_role_user');
Schema::drop('rbac_permission_role');
Schema::drop('rbac_permissions');
Schema::drop('rbac_roles');
Schema::dropIfExists('rbac_role_user');
Schema::dropIfExists('rbac_permission_role');
Schema::dropIfExists('rbac_permissions');
Schema::dropIfExists('rbac_permission_groups');
Schema::dropIfExists('rbac_roles');
}
}

0 comments on commit 4969ac6

Please sign in to comment.