Skip to content

Commit

Permalink
Improvements (caffeinated#109)
Browse files Browse the repository at this point in the history
* Work on tests

* all tests pass green

* Add simple blade directive tests

* Improved @ROLE directive and added means to customize table names
  • Loading branch information
kaidesu authored Jun 27, 2019
1 parent 5a5df66 commit cbdebfc
Show file tree
Hide file tree
Showing 31 changed files with 993 additions and 58 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
vendor/
composer.lock
/.idea/*
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":14334:{a:2:{s:7:"defects";a:57:{s:61:"Caffeinated\Shinobi\Tests\Feature\GrumpyTest::it_returns_true";i:4;s:66:"Caffeinated\Shinobi\Tests\Feature\GrumpyTest::it_has_a_users_table";i:3;s:88:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_permissions_to_roles";i:3;s:90:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_a_permission_to_a_role";i:4;s:98:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_multiple_permissions_to_a_role";i:4;s:96:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_a_permission_to_a_role_by_id";i:4;s:98:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_a_permission_to_a_role_by_slug";i:4;s:107:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_multiple_permissions_to_a_role_by_slugs";i:4;s:97:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assert_a_role_has_a_given_permission";i:4;s:110:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assert_a_role_with_no_access_never_has_permission";i:4;s:107:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assert_a_role_does_not_have_a_given_permission";i:4;s:112:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assert_a_role_with_all_access_always_has_permission";i:4;s:92:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_revoke_a_permission_from_a_role";i:4;s:88:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_give_a_permission_to_a_role";i:4;s:96:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_give_a_permission_to_a_role_by_slug";i:4;s:96:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_give_multiple_permissions_to_a_role";i:4;s:105:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_give_multiple_permissions_to_a_role_by_slugs";i:4;s:100:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_revoke_a_permission_from_a_role_by_slug";i:4;s:100:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_revoke_multiple_permissions_from_a_role";i:4;s:109:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_revoke_multiple_permissions_from_a_role_by_slugs";i:4;s:64:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_given_a_permission";i:4;s:72:"Caffeinated\Shinobi\Tests\UserTest::it_can_assert_has_a_given_permission";i:4;s:82:"Caffeinated\Shinobi\Tests\UserTest::it_can_assert_does_not_have_a_given_permission";i:4;s:61:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_assigned_a_role";i:4;s:100:"Caffeinated\Shinobi\Tests\UserTest::it_has_no_permissions_when_assigned_a_role_with_a_no_access_flag";i:4;s:90:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_with_no_access_flag_never_has_permission";i:4;s:92:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_with_all_access_flag_always_has_permission";i:4;s:74:"Caffeinated\Shinobi\Tests\UserTest::it_has_a_given_permission_through_role";i:4;s:72:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_has_a_given_permission";i:4;s:82:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_does_not_have_a_given_permission";i:4;s:53:"Caffeinated\Shinobi\Tests\GrumpyTest::it_returns_true";i:4;s:61:"Caffeinated\Shinobi\Tests\GrumpyTest::it_has_necessary_tables";i:3;s:64:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_given_a_permission";i:4;s:72:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_given_a_permission_by_slug";i:4;s:72:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_given_multiple_permissions";i:4;s:80:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_given_multiple_permissions_by_slug";i:4;s:66:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_revoked_a_permission";i:4;s:74:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_revoked_a_permission_by_slug";i:4;s:74:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_revoked_multiple_permissions";i:4;s:83:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_revoked_multiple_permissions_by_slugs";i:4;s:72:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_given_a_permission_by_slug";i:4;s:72:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_given_multiple_permissions";i:4;s:80:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_given_multiple_permissions_by_slug";i:4;s:66:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_revoked_a_permission";i:4;s:74:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_revoked_a_permission_by_slug";i:4;s:74:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_revoked_multiple_permissions";i:4;s:83:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_revoked_multiple_permissions_by_slugs";i:4;s:69:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_assigned_a_role_by_slug";i:4;s:69:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_assigned_multiple_roles";i:4;s:78:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_assigned_multiple_roles_by_slugs";i:4;s:94:"Caffeinated\Shinobi\Tests\BladeTest::the_can_directive_evaluates_true_when_permissions_are_met";i:3;s:101:"Caffeinated\Shinobi\Tests\BladeTest::the_cannot_directive_evaluates_true_when_permissions_are_not_met";i:4;s:98:"Caffeinated\Shinobi\Tests\BladeTest::the_cannot_directive_evaluates_false_when_permissions_are_met";i:3;s:99:"Caffeinated\Shinobi\Tests\BladeTest::the_can_directive_evaluates_false_when_permissions_are_not_met";i:4;s:95:"Caffeinated\Shinobi\Tests\BladeTest::the_role_directive_evaluates_true_when_user_has_given_role";i:4;s:107:"Caffeinated\Shinobi\Tests\BladeTest::the_role_directive_evaluates_false_when_user_does_not_have_given_roles";i:4;s:61:"Caffeinated\Shinobi\Tests\BladeTest::guests_do_not_have_roles";i:4;}s:5:"times";a:87:{s:61:"Caffeinated\Shinobi\Tests\Feature\GrumpyTest::it_returns_true";d:0.124;s:66:"Caffeinated\Shinobi\Tests\Feature\GrumpyTest::is_has_a_users_table";d:0.11;s:66:"Caffeinated\Shinobi\Tests\Feature\GrumpyTest::it_has_a_users_table";d:0.017;s:69:"Caffeinated\Shinobi\Tests\Feature\GrumpyTest::it_has_necessary_tables";d:0.015;s:69:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_returns_true";d:0.018;s:88:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_permissions_to_roles";d:0.025;s:98:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_multiple_permissions_to_a_role";d:0.019;s:90:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_a_permission_to_a_role";d:0.024;s:96:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_a_permission_to_a_role_by_id";d:0.022;s:98:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_a_permission_to_a_role_by_slug";d:0.016;s:107:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assign_multiple_permissions_to_a_role_by_slugs";d:0.02;s:97:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assert_a_role_has_a_given_permission";d:0.02;s:107:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assert_a_role_does_not_have_a_given_permission";d:0.016;s:110:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assert_a_role_with_no_access_never_has_permission";d:0.017;s:112:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_assert_a_role_with_all_access_always_has_permission";d:0.016;s:92:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_revoke_a_permission_from_a_role";d:0.017;s:88:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_give_a_permission_to_a_role";d:0.025;s:96:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_give_a_permission_to_a_role_by_slug";d:0.02;s:96:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_give_multiple_permissions_to_a_role";d:0.019;s:105:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_give_multiple_permissions_to_a_role_by_slugs";d:0.019;s:100:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_revoke_a_permission_from_a_role_by_slug";d:0.019;s:100:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_revoke_multiple_permissions_from_a_role";d:0.02;s:109:"Caffeinated\Shinobi\Tests\Feature\HasPermissionsTest::it_can_revoke_multiple_permissions_from_a_role_by_slugs";d:0.022;s:53:"Caffeinated\Shinobi\Tests\GrumpyTest::it_returns_true";d:0.014;s:61:"Caffeinated\Shinobi\Tests\GrumpyTest::it_has_necessary_tables";d:0.015;s:80:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_give_a_permission_to_a_role";d:0.026;s:88:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_give_a_permission_to_a_role_by_slug";d:0.017;s:88:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_give_multiple_permissions_to_a_role";d:0.02;s:97:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_give_multiple_permissions_to_a_role_by_slugs";d:0.021;s:84:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_revoke_a_permission_from_a_role";d:0.017;s:92:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_revoke_a_permission_from_a_role_by_slug";d:0.02;s:92:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_revoke_multiple_permissions_from_a_role";d:0.02;s:101:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_revoke_multiple_permissions_from_a_role_by_slugs";d:0.023;s:89:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_assert_a_role_has_a_given_permission";d:0.018;s:99:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_assert_a_role_does_not_have_a_given_permission";d:0.017;s:102:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_assert_a_role_with_no_access_never_has_permission";d:0.016;s:104:"Caffeinated\Shinobi\Tests\HasPermissionsTest::it_can_assert_a_role_with_all_access_always_has_permission";d:0.017;s:70:"Caffeinated\Shinobi\Tests\RoleTest::it_can_give_a_permission_to_a_role";d:0.027;s:78:"Caffeinated\Shinobi\Tests\RoleTest::it_can_give_a_permission_to_a_role_by_slug";d:0.017;s:78:"Caffeinated\Shinobi\Tests\RoleTest::it_can_give_multiple_permissions_to_a_role";d:0.022;s:87:"Caffeinated\Shinobi\Tests\RoleTest::it_can_give_multiple_permissions_to_a_role_by_slugs";d:0.027;s:74:"Caffeinated\Shinobi\Tests\RoleTest::it_can_revoke_a_permission_from_a_role";d:0.018;s:82:"Caffeinated\Shinobi\Tests\RoleTest::it_can_revoke_a_permission_from_a_role_by_slug";d:0.018;s:82:"Caffeinated\Shinobi\Tests\RoleTest::it_can_revoke_multiple_permissions_from_a_role";d:0.018;s:91:"Caffeinated\Shinobi\Tests\RoleTest::it_can_revoke_multiple_permissions_from_a_role_by_slugs";d:0.021;s:79:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_a_role_has_a_given_permission";d:0.018;s:89:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_a_role_does_not_have_a_given_permission";d:0.016;s:92:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_a_role_with_no_access_never_has_permission";d:0.016;s:94:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_a_role_with_all_access_always_has_permission";d:0.016;s:64:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_given_a_permission";d:0.017;s:72:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_given_a_permission_by_slug";d:0.018;s:72:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_given_multiple_permissions";d:0.018;s:80:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_given_multiple_permissions_by_slug";d:0.02;s:66:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_revoked_a_permission";d:0.022;s:74:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_revoked_a_permission_by_slug";d:0.016;s:74:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_revoked_multiple_permissions";d:0.017;s:83:"Caffeinated\Shinobi\Tests\RoleTest::it_can_be_revoked_multiple_permissions_by_slugs";d:0.02;s:72:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_has_a_given_permission";d:0.018;s:82:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_does_not_have_a_given_permission";d:0.015;s:90:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_with_no_access_flag_never_has_permission";d:0.017;s:92:"Caffeinated\Shinobi\Tests\RoleTest::it_can_assert_with_all_access_flag_always_has_permission";d:0.014;s:64:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_given_a_permission";d:0.018;s:72:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_given_a_permission_by_slug";d:0.017;s:72:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_given_multiple_permissions";d:0.02;s:80:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_given_multiple_permissions_by_slug";d:0.022;s:66:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_revoked_a_permission";d:0.018;s:74:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_revoked_a_permission_by_slug";d:0.019;s:74:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_revoked_multiple_permissions";d:0.021;s:83:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_revoked_multiple_permissions_by_slugs";d:0.027;s:72:"Caffeinated\Shinobi\Tests\UserTest::it_can_assert_has_a_given_permission";d:0.018;s:82:"Caffeinated\Shinobi\Tests\UserTest::it_can_assert_does_not_have_a_given_permission";d:0.019;s:61:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_assigned_a_role";d:0.017;s:69:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_assigned_a_role_by_slug";d:0.018;s:69:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_assigned_multiple_roles";d:0.019;s:78:"Caffeinated\Shinobi\Tests\UserTest::it_can_be_assigned_multiple_roles_by_slugs";d:0.021;s:85:"Caffeinated\Shinobi\Tests\UserTest::it_can_assert_has_a_given_permission_through_role";d:0.02;s:74:"Caffeinated\Shinobi\Tests\UserTest::it_has_a_given_permission_through_role";d:0.02;s:100:"Caffeinated\Shinobi\Tests\UserTest::it_has_no_permissions_when_assigned_a_role_with_a_no_access_flag";d:0.018;s:87:"Caffeinated\Shinobi\Tests\BladeTest::the_can_directive_renders_when_permissions_are_met";d:0.128;s:94:"Caffeinated\Shinobi\Tests\BladeTest::the_can_directive_evaluates_true_when_permissions_are_met";d:0.13;s:99:"Caffeinated\Shinobi\Tests\BladeTest::the_can_directive_evaluates_false_when_permissions_are_not_met";d:0.019;s:101:"Caffeinated\Shinobi\Tests\BladeTest::the_cannot_directive_evaluates_true_when_permissions_are_not_met";d:0.02;s:98:"Caffeinated\Shinobi\Tests\BladeTest::the_cannot_directive_evaluates_false_when_permissions_are_met";d:0.037;s:95:"Caffeinated\Shinobi\Tests\BladeTest::the_role_directive_evaluates_true_when_user_has_given_role";d:0.018;s:121:"Caffeinated\Shinobi\Tests\BladeTest::the_role_directive_evaluates_true_if_previous_evaluations_didnt_pass_when_using_else";d:0.036;s:107:"Caffeinated\Shinobi\Tests\BladeTest::the_role_directive_evaluates_false_when_user_does_not_have_given_roles";d:0.017;s:61:"Caffeinated\Shinobi\Tests\BladeTest::guests_do_not_have_roles";d:0.016;}}}
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"Caffeinated\\Shinobi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Caffeinated\\Shinobi\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
Expand All @@ -25,5 +30,9 @@
}
}
},
"minimum-stability": "dev"
"minimum-stability": "dev",
"require-dev": {
"orchestra/testbench": "^3.7",
"doctrine/dbal": "^2.10@dev"
}
}
21 changes: 21 additions & 0 deletions config/shinobi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return [

'models' => [

/*
|--------------------------------------------------------------------------
| Model References
Expand All @@ -18,6 +19,26 @@

],

'tables' => [

/*
|--------------------------------------------------------------------------
| Table References
|--------------------------------------------------------------------------
|
| When customizing the models used by Shinobi, you may also wish to
| customize the table names as well. You will want to publish the
| bundled migrations and update the references here for use.
*/

'roles' => 'roles',
'permissions' => 'permissions',
'role_user' => 'role_user',
'permission_role' => 'permission_role',
'permission_user' => 'permission_user',

],

/*
|--------------------------------------------------------------------------
| Use Migrations
Expand Down
8 changes: 6 additions & 2 deletions migrations/2015_01_20_084450_create_roles_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class CreateRolesTable extends Migration
*/
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$name = config('shinobi.tables.roles');

Schema::create($name, function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->string('slug')->unique();
Expand All @@ -28,6 +30,8 @@ public function up()
*/
public function down()
{
Schema::drop('roles');
$name = config('shinobi.tables.roles');

Schema::drop($name);
}
}
8 changes: 6 additions & 2 deletions migrations/2015_01_20_084525_create_role_user_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class CreateRoleUserTable extends Migration
*/
public function up()
{
Schema::create('role_user', function (Blueprint $table) {
$name = config('shinobi.tables.role_user');

Schema::create($name, function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('role_id')->index();
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
Expand All @@ -29,6 +31,8 @@ public function up()
*/
public function down()
{
Schema::drop('role_user');
$name = config('shinobi.tables.role_user');

Schema::drop($name);
}
}
8 changes: 6 additions & 2 deletions migrations/2015_01_24_080208_create_permissions_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class CreatePermissionsTable extends Migration
*/
public function up()
{
Schema::create('permissions', function (Blueprint $table) {
$name = config('shinobi.tables.permissions');

Schema::create($name, function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('slug')->unique();
Expand All @@ -28,6 +30,8 @@ public function up()
*/
public function down()
{
Schema::drop('permissions');
$name = config('shinobi.tables.permissions');

Schema::drop($name);
}
}
8 changes: 6 additions & 2 deletions migrations/2015_01_24_080433_create_permission_role_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class CreatePermissionRoleTable extends Migration
*/
public function up()
{
Schema::create('permission_role', function (Blueprint $table) {
$name = config('shinobi.tables.permission_role');

Schema::create($name, function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('permission_id')->index();
$table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
Expand All @@ -29,6 +31,8 @@ public function up()
*/
public function down()
{
Schema::drop('permission_role');
$name = config('shinobi.tables.permission_role');

Schema::drop($name);
}
}
8 changes: 6 additions & 2 deletions migrations/2015_12_04_003040_add_special_role_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class AddSpecialRoleColumn extends Migration
*/
public function up()
{
Schema::table('roles', function ($table) {
$name = config('shinobi.tables.roles');

Schema::table($name, function ($table) {
$table->enum('special', ['all-access', 'no-access'])->nullable();
});
}
Expand All @@ -23,7 +25,9 @@ public function up()
*/
public function down()
{
Schema::table('roles', function ($table) {
$name = config('shinobi.tables.roles');

Schema::table($name, function ($table) {
$table->dropColumn('special');
});
}
Expand Down
8 changes: 6 additions & 2 deletions migrations/2017_10_17_170735_create_permission_user_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class CreatePermissionUserTable extends Migration
{
public function up()
{
Schema::create('permission_user', function (Blueprint $table) {
$name = config('shinobi.tables.permission_user');

Schema::create($name, function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('permission_id')->index();
$table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
Expand All @@ -25,7 +27,9 @@ public function up()
*/
public function down()
{
Schema::drop('permission_user');
$name = config('shinobi.tables.permission_user');

Schema::drop($name);
}

}
Loading

0 comments on commit cbdebfc

Please sign in to comment.