@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreatePasswordResetsTable extends Migration |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function up() |
|
| 15 | - { |
|
| 16 | - Schema::create('password_resets', function (Blueprint $table) { |
|
| 17 | - $table->string('email')->index(); |
|
| 18 | - $table->string('token'); |
|
| 19 | - $table->timestamp('created_at')->nullable(); |
|
| 20 | - }); |
|
| 21 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function up() |
|
| 15 | + { |
|
| 16 | + Schema::create('password_resets', function (Blueprint $table) { |
|
| 17 | + $table->string('email')->index(); |
|
| 18 | + $table->string('token'); |
|
| 19 | + $table->timestamp('created_at')->nullable(); |
|
| 20 | + }); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Reverse the migrations. |
|
| 25 | - * |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function down() |
|
| 29 | - { |
|
| 30 | - Schema::dropIfExists('password_resets'); |
|
| 31 | - } |
|
| 23 | + /** |
|
| 24 | + * Reverse the migrations. |
|
| 25 | + * |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function down() |
|
| 29 | + { |
|
| 30 | + Schema::dropIfExists('password_resets'); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('password_resets', function (Blueprint $table) { |
|
| 16 | + Schema::create('password_resets', function(Blueprint $table) { |
|
| 17 | 17 | $table->string('email')->index(); |
| 18 | 18 | $table->string('token'); |
| 19 | 19 | $table->timestamp('created_at')->nullable(); |
@@ -6,31 +6,31 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreateUsersTable extends Migration |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function up() |
|
| 15 | - { |
|
| 16 | - Schema::create('users', function (Blueprint $table) { |
|
| 17 | - $table->bigIncrements('id'); |
|
| 18 | - $table->string('name'); |
|
| 19 | - $table->string('email')->unique(); |
|
| 20 | - $table->timestamp('email_verified_at')->nullable(); |
|
| 21 | - $table->string('password'); |
|
| 22 | - $table->rememberToken(); |
|
| 23 | - $table->timestamps(); |
|
| 24 | - }); |
|
| 25 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function up() |
|
| 15 | + { |
|
| 16 | + Schema::create('users', function (Blueprint $table) { |
|
| 17 | + $table->bigIncrements('id'); |
|
| 18 | + $table->string('name'); |
|
| 19 | + $table->string('email')->unique(); |
|
| 20 | + $table->timestamp('email_verified_at')->nullable(); |
|
| 21 | + $table->string('password'); |
|
| 22 | + $table->rememberToken(); |
|
| 23 | + $table->timestamps(); |
|
| 24 | + }); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Reverse the migrations. |
|
| 29 | - * |
|
| 30 | - * @return void |
|
| 31 | - */ |
|
| 32 | - public function down() |
|
| 33 | - { |
|
| 34 | - Schema::dropIfExists('users'); |
|
| 35 | - } |
|
| 27 | + /** |
|
| 28 | + * Reverse the migrations. |
|
| 29 | + * |
|
| 30 | + * @return void |
|
| 31 | + */ |
|
| 32 | + public function down() |
|
| 33 | + { |
|
| 34 | + Schema::dropIfExists('users'); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('users', function (Blueprint $table) { |
|
| 16 | + Schema::create('users', function(Blueprint $table) { |
|
| 17 | 17 | $table->bigIncrements('id'); |
| 18 | 18 | $table->string('name'); |
| 19 | 19 | $table->string('email')->unique(); |
@@ -6,97 +6,97 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreatePermissionTables extends Migration |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function up() |
|
| 15 | - { |
|
| 16 | - $tableNames = config('permission.table_names'); |
|
| 17 | - $columnNames = config('permission.column_names'); |
|
| 18 | - |
|
| 19 | - Schema::create($tableNames['permissions'], function (Blueprint $table) { |
|
| 20 | - $table->bigIncrements('id'); |
|
| 21 | - $table->string('name'); |
|
| 22 | - $table->string('guard_name'); |
|
| 23 | - $table->timestamps(); |
|
| 24 | - }); |
|
| 25 | - |
|
| 26 | - Schema::create($tableNames['roles'], function (Blueprint $table) { |
|
| 27 | - $table->bigIncrements('id'); |
|
| 28 | - $table->string('name'); |
|
| 29 | - $table->string('guard_name'); |
|
| 30 | - $table->timestamps(); |
|
| 31 | - }); |
|
| 32 | - |
|
| 33 | - Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
| 34 | - $table->unsignedBigInteger('permission_id'); |
|
| 35 | - |
|
| 36 | - $table->string('model_type'); |
|
| 37 | - $table->unsignedBigInteger($columnNames['model_morph_key']); |
|
| 38 | - $table->index([$columnNames['model_morph_key'], 'model_type', ], 'model_has_permissions_model_id_model_type_index'); |
|
| 39 | - |
|
| 40 | - $table->foreign('permission_id') |
|
| 41 | - ->references('id') |
|
| 42 | - ->on($tableNames['permissions']) |
|
| 43 | - ->onDelete('cascade'); |
|
| 44 | - |
|
| 45 | - $table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'], |
|
| 46 | - 'model_has_permissions_permission_model_type_primary'); |
|
| 47 | - }); |
|
| 48 | - |
|
| 49 | - Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
| 50 | - $table->unsignedBigInteger('role_id'); |
|
| 51 | - |
|
| 52 | - $table->string('model_type'); |
|
| 53 | - $table->unsignedBigInteger($columnNames['model_morph_key']); |
|
| 54 | - $table->index([$columnNames['model_morph_key'], 'model_type', ], 'model_has_roles_model_id_model_type_index'); |
|
| 55 | - |
|
| 56 | - $table->foreign('role_id') |
|
| 57 | - ->references('id') |
|
| 58 | - ->on($tableNames['roles']) |
|
| 59 | - ->onDelete('cascade'); |
|
| 60 | - |
|
| 61 | - $table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'], |
|
| 62 | - 'model_has_roles_role_model_type_primary'); |
|
| 63 | - }); |
|
| 64 | - |
|
| 65 | - Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { |
|
| 66 | - $table->unsignedBigInteger('permission_id'); |
|
| 67 | - $table->unsignedBigInteger('role_id'); |
|
| 68 | - |
|
| 69 | - $table->foreign('permission_id') |
|
| 70 | - ->references('id') |
|
| 71 | - ->on($tableNames['permissions']) |
|
| 72 | - ->onDelete('cascade'); |
|
| 73 | - |
|
| 74 | - $table->foreign('role_id') |
|
| 75 | - ->references('id') |
|
| 76 | - ->on($tableNames['roles']) |
|
| 77 | - ->onDelete('cascade'); |
|
| 78 | - |
|
| 79 | - $table->primary(['permission_id', 'role_id'], 'role_has_permissions_permission_id_role_id_primary'); |
|
| 80 | - }); |
|
| 81 | - |
|
| 82 | - app('cache') |
|
| 83 | - ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) |
|
| 84 | - ->forget(config('permission.cache.key')); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Reverse the migrations. |
|
| 89 | - * |
|
| 90 | - * @return void |
|
| 91 | - */ |
|
| 92 | - public function down() |
|
| 93 | - { |
|
| 94 | - $tableNames = config('permission.table_names'); |
|
| 95 | - |
|
| 96 | - Schema::drop($tableNames['role_has_permissions']); |
|
| 97 | - Schema::drop($tableNames['model_has_roles']); |
|
| 98 | - Schema::drop($tableNames['model_has_permissions']); |
|
| 99 | - Schema::drop($tableNames['roles']); |
|
| 100 | - Schema::drop($tableNames['permissions']); |
|
| 101 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function up() |
|
| 15 | + { |
|
| 16 | + $tableNames = config('permission.table_names'); |
|
| 17 | + $columnNames = config('permission.column_names'); |
|
| 18 | + |
|
| 19 | + Schema::create($tableNames['permissions'], function (Blueprint $table) { |
|
| 20 | + $table->bigIncrements('id'); |
|
| 21 | + $table->string('name'); |
|
| 22 | + $table->string('guard_name'); |
|
| 23 | + $table->timestamps(); |
|
| 24 | + }); |
|
| 25 | + |
|
| 26 | + Schema::create($tableNames['roles'], function (Blueprint $table) { |
|
| 27 | + $table->bigIncrements('id'); |
|
| 28 | + $table->string('name'); |
|
| 29 | + $table->string('guard_name'); |
|
| 30 | + $table->timestamps(); |
|
| 31 | + }); |
|
| 32 | + |
|
| 33 | + Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
| 34 | + $table->unsignedBigInteger('permission_id'); |
|
| 35 | + |
|
| 36 | + $table->string('model_type'); |
|
| 37 | + $table->unsignedBigInteger($columnNames['model_morph_key']); |
|
| 38 | + $table->index([$columnNames['model_morph_key'], 'model_type', ], 'model_has_permissions_model_id_model_type_index'); |
|
| 39 | + |
|
| 40 | + $table->foreign('permission_id') |
|
| 41 | + ->references('id') |
|
| 42 | + ->on($tableNames['permissions']) |
|
| 43 | + ->onDelete('cascade'); |
|
| 44 | + |
|
| 45 | + $table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'], |
|
| 46 | + 'model_has_permissions_permission_model_type_primary'); |
|
| 47 | + }); |
|
| 48 | + |
|
| 49 | + Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
| 50 | + $table->unsignedBigInteger('role_id'); |
|
| 51 | + |
|
| 52 | + $table->string('model_type'); |
|
| 53 | + $table->unsignedBigInteger($columnNames['model_morph_key']); |
|
| 54 | + $table->index([$columnNames['model_morph_key'], 'model_type', ], 'model_has_roles_model_id_model_type_index'); |
|
| 55 | + |
|
| 56 | + $table->foreign('role_id') |
|
| 57 | + ->references('id') |
|
| 58 | + ->on($tableNames['roles']) |
|
| 59 | + ->onDelete('cascade'); |
|
| 60 | + |
|
| 61 | + $table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'], |
|
| 62 | + 'model_has_roles_role_model_type_primary'); |
|
| 63 | + }); |
|
| 64 | + |
|
| 65 | + Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { |
|
| 66 | + $table->unsignedBigInteger('permission_id'); |
|
| 67 | + $table->unsignedBigInteger('role_id'); |
|
| 68 | + |
|
| 69 | + $table->foreign('permission_id') |
|
| 70 | + ->references('id') |
|
| 71 | + ->on($tableNames['permissions']) |
|
| 72 | + ->onDelete('cascade'); |
|
| 73 | + |
|
| 74 | + $table->foreign('role_id') |
|
| 75 | + ->references('id') |
|
| 76 | + ->on($tableNames['roles']) |
|
| 77 | + ->onDelete('cascade'); |
|
| 78 | + |
|
| 79 | + $table->primary(['permission_id', 'role_id'], 'role_has_permissions_permission_id_role_id_primary'); |
|
| 80 | + }); |
|
| 81 | + |
|
| 82 | + app('cache') |
|
| 83 | + ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) |
|
| 84 | + ->forget(config('permission.cache.key')); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Reverse the migrations. |
|
| 89 | + * |
|
| 90 | + * @return void |
|
| 91 | + */ |
|
| 92 | + public function down() |
|
| 93 | + { |
|
| 94 | + $tableNames = config('permission.table_names'); |
|
| 95 | + |
|
| 96 | + Schema::drop($tableNames['role_has_permissions']); |
|
| 97 | + Schema::drop($tableNames['model_has_roles']); |
|
| 98 | + Schema::drop($tableNames['model_has_permissions']); |
|
| 99 | + Schema::drop($tableNames['roles']); |
|
| 100 | + Schema::drop($tableNames['permissions']); |
|
| 101 | + } |
|
| 102 | 102 | } |
@@ -16,21 +16,21 @@ discard block |
||
| 16 | 16 | $tableNames = config('permission.table_names'); |
| 17 | 17 | $columnNames = config('permission.column_names'); |
| 18 | 18 | |
| 19 | - Schema::create($tableNames['permissions'], function (Blueprint $table) { |
|
| 19 | + Schema::create($tableNames['permissions'], function(Blueprint $table) { |
|
| 20 | 20 | $table->bigIncrements('id'); |
| 21 | 21 | $table->string('name'); |
| 22 | 22 | $table->string('guard_name'); |
| 23 | 23 | $table->timestamps(); |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | - Schema::create($tableNames['roles'], function (Blueprint $table) { |
|
| 26 | + Schema::create($tableNames['roles'], function(Blueprint $table) { |
|
| 27 | 27 | $table->bigIncrements('id'); |
| 28 | 28 | $table->string('name'); |
| 29 | 29 | $table->string('guard_name'); |
| 30 | 30 | $table->timestamps(); |
| 31 | 31 | }); |
| 32 | 32 | |
| 33 | - Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
| 33 | + Schema::create($tableNames['model_has_permissions'], function(Blueprint $table) use ($tableNames, $columnNames) { |
|
| 34 | 34 | $table->unsignedBigInteger('permission_id'); |
| 35 | 35 | |
| 36 | 36 | $table->string('model_type'); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | 'model_has_permissions_permission_model_type_primary'); |
| 47 | 47 | }); |
| 48 | 48 | |
| 49 | - Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
| 49 | + Schema::create($tableNames['model_has_roles'], function(Blueprint $table) use ($tableNames, $columnNames) { |
|
| 50 | 50 | $table->unsignedBigInteger('role_id'); |
| 51 | 51 | |
| 52 | 52 | $table->string('model_type'); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | 'model_has_roles_role_model_type_primary'); |
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | - Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { |
|
| 65 | + Schema::create($tableNames['role_has_permissions'], function(Blueprint $table) use ($tableNames) { |
|
| 66 | 66 | $table->unsignedBigInteger('permission_id'); |
| 67 | 67 | $table->unsignedBigInteger('role_id'); |
| 68 | 68 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | public static function boot() |
| 51 | 51 | { |
| 52 | 52 | // allow Super Admin full access |
| 53 | - Gate::after(function ($user, $ability) { |
|
| 53 | + Gate::after(function($user, $ability) { |
|
| 54 | 54 | return $user->hasRole('Super Admin'); |
| 55 | 55 | }); |
| 56 | 56 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | protected function showEditPermissions() |
| 37 | 37 | { |
| 38 | - $permissionsData = Permission::all(['id', 'name'])->map(function($permission){ |
|
| 38 | + $permissionsData = Permission::all(['id', 'name'])->map(function($permission) { |
|
| 39 | 39 | $permission['name'] = trans(ucwords($permission['name'])); |
| 40 | 40 | |
| 41 | 41 | return $permission; |
@@ -99,19 +99,19 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | protected function columns() |
| 101 | 101 | { |
| 102 | - return $this->columns = $this->columns?: $this->add('Columns'); |
|
| 102 | + return $this->columns = $this->columns ?: $this->add('Columns'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | protected function permissionId() |
| 106 | 106 | { |
| 107 | - return $this->app->stickyGet($this->columns()->name)?: $this->getModuleVariable('permission'); |
|
| 107 | + return $this->app->stickyGet($this->columns()->name) ?: $this->getModuleVariable('permission'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | protected function reload($permissionExpression = null) |
| 111 | 111 | { |
| 112 | 112 | $columns = $this->columns(); |
| 113 | 113 | |
| 114 | - return $this->reload = $this->reload?: new jsReload($columns, [$columns->name => $permissionExpression?: '']); |
|
| 114 | + return $this->reload = $this->reload ?: new jsReload($columns, [$columns->name => $permissionExpression ?: '']); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | protected function getModel($array) |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | private static function cacheUserVariables() { |
| 26 | - if(isset(self::$userVariables)) return; |
|
| 26 | + if (isset(self::$userVariables)) return; |
|
| 27 | 27 | |
| 28 | 28 | $userId = Auth::id(); |
| 29 | 29 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | private static function cacheAdminVariables() { |
| 36 | - if(isset(self::$adminVariables)) return; |
|
| 36 | + if (isset(self::$adminVariables)) return; |
|
| 37 | 37 | |
| 38 | 38 | foreach (self::where('user_id', 0) as $row) { |
| 39 | 39 | self::$adminVariables[$row['group']][$row['name']] = $row['value']; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public static function get($group, $name, $user = null) { |
| 44 | - $user = $user?: Auth::id(); |
|
| 44 | + $user = $user ?: Auth::id(); |
|
| 45 | 45 | |
| 46 | 46 | if (!$user || !is_numeric($user)) return; |
| 47 | 47 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public static function getGroup($group, $user = null) { |
| 54 | - $user = $user?: Auth::id(); |
|
| 54 | + $user = $user ?: Auth::id(); |
|
| 55 | 55 | |
| 56 | 56 | if (!$user || !is_numeric($user)) return; |
| 57 | 57 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public static function put($group, $name, $value, $user = null) { |
| 76 | - $user_id = $user?: Auth::id(); |
|
| 76 | + $user_id = $user ?: Auth::id(); |
|
| 77 | 77 | |
| 78 | 78 | if (!$user_id || !is_numeric($user_id)) return; |
| 79 | 79 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public static function forget($group, $name, $user = null) { |
| 104 | - $user_id = $user?: Auth::id(); |
|
| 104 | + $user_id = $user ?: Auth::id(); |
|
| 105 | 105 | |
| 106 | 106 | if (!$user_id || !is_numeric($user_id)) return; |
| 107 | 107 | |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | private static function cacheUserVariables() { |
| 26 | - if(isset(self::$userVariables)) return; |
|
| 26 | + if(isset(self::$userVariables)) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | $userId = Auth::id(); |
| 29 | 31 | |
@@ -33,7 +35,9 @@ discard block |
||
| 33 | 35 | } |
| 34 | 36 | |
| 35 | 37 | private static function cacheAdminVariables() { |
| 36 | - if(isset(self::$adminVariables)) return; |
|
| 38 | + if(isset(self::$adminVariables)) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 37 | 41 | |
| 38 | 42 | foreach (self::where('user_id', 0) as $row) { |
| 39 | 43 | self::$adminVariables[$row['group']][$row['name']] = $row['value']; |
@@ -43,7 +47,9 @@ discard block |
||
| 43 | 47 | public static function get($group, $name, $user = null) { |
| 44 | 48 | $user = $user?: Auth::id(); |
| 45 | 49 | |
| 46 | - if (!$user || !is_numeric($user)) return; |
|
| 50 | + if (!$user || !is_numeric($user)) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 47 | 53 | |
| 48 | 54 | self::cache(); |
| 49 | 55 | |
@@ -53,7 +59,9 @@ discard block |
||
| 53 | 59 | public static function getGroup($group, $user = null) { |
| 54 | 60 | $user = $user?: Auth::id(); |
| 55 | 61 | |
| 56 | - if (!$user || !is_numeric($user)) return; |
|
| 62 | + if (!$user || !is_numeric($user)) { |
|
| 63 | + return; |
|
| 64 | + } |
|
| 57 | 65 | |
| 58 | 66 | self::cache(); |
| 59 | 67 | |
@@ -75,7 +83,9 @@ discard block |
||
| 75 | 83 | public static function put($group, $name, $value, $user = null) { |
| 76 | 84 | $user_id = $user?: Auth::id(); |
| 77 | 85 | |
| 78 | - if (!$user_id || !is_numeric($user_id)) return; |
|
| 86 | + if (!$user_id || !is_numeric($user_id)) { |
|
| 87 | + return; |
|
| 88 | + } |
|
| 79 | 89 | |
| 80 | 90 | self::cache(); |
| 81 | 91 | |
@@ -103,7 +113,9 @@ discard block |
||
| 103 | 113 | public static function forget($group, $name, $user = null) { |
| 104 | 114 | $user_id = $user?: Auth::id(); |
| 105 | 115 | |
| 106 | - if (!$user_id || !is_numeric($user_id)) return; |
|
| 116 | + if (!$user_id || !is_numeric($user_id)) { |
|
| 117 | + return; |
|
| 118 | + } |
|
| 107 | 119 | |
| 108 | 120 | self::cache(); |
| 109 | 121 | |
@@ -6,31 +6,31 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreateUserSettingsTable extends Migration |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function up() |
|
| 15 | - { |
|
| 16 | - $this->down(); |
|
| 9 | + /** |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function up() |
|
| 15 | + { |
|
| 16 | + $this->down(); |
|
| 17 | 17 | |
| 18 | - Schema::create('user_settings', function (Blueprint $table) { |
|
| 19 | - $table->increments('id'); |
|
| 20 | - $table->unsignedInteger('user_id'); |
|
| 21 | - $table->string('group', 512); |
|
| 22 | - $table->string('name', 128); |
|
| 23 | - $table->text('value'); |
|
| 24 | - }); |
|
| 25 | - } |
|
| 18 | + Schema::create('user_settings', function (Blueprint $table) { |
|
| 19 | + $table->increments('id'); |
|
| 20 | + $table->unsignedInteger('user_id'); |
|
| 21 | + $table->string('group', 512); |
|
| 22 | + $table->string('name', 128); |
|
| 23 | + $table->text('value'); |
|
| 24 | + }); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Reverse the migrations. |
|
| 29 | - * |
|
| 30 | - * @return void |
|
| 31 | - */ |
|
| 32 | - public function down() |
|
| 33 | - { |
|
| 34 | - Schema::dropIfExists('user_settings'); |
|
| 35 | - } |
|
| 27 | + /** |
|
| 28 | + * Reverse the migrations. |
|
| 29 | + * |
|
| 30 | + * @return void |
|
| 31 | + */ |
|
| 32 | + public function down() |
|
| 33 | + { |
|
| 34 | + Schema::dropIfExists('user_settings'); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | { |
| 16 | 16 | $this->down(); |
| 17 | 17 | |
| 18 | - Schema::create('user_settings', function (Blueprint $table) { |
|
| 18 | + Schema::create('user_settings', function(Blueprint $table) { |
|
| 19 | 19 | $table->increments('id'); |
| 20 | 20 | $table->unsignedInteger('user_id'); |
| 21 | 21 | $table->string('group', 512); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function group() |
| 27 | 27 | { |
| 28 | - return $this->group?: static::class; |
|
| 28 | + return $this->group ?: static::class; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | public static function getClass($classOrAlias, $installedOnly = false) { |
| 37 | 37 | $modules = $installedOnly? self::getInstalled(): self::getAll(); |
| 38 | 38 | |
| 39 | - if (collect($modules)->contains($classOrAlias)) return $classOrAlias; |
|
| 39 | + if (collect($modules)->contains($classOrAlias)) { |
|
| 40 | + return $classOrAlias; |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | return $modules[$classOrAlias]?? null; |
| 42 | 44 | } |
@@ -88,7 +90,9 @@ discard block |
||
| 88 | 90 | |
| 89 | 91 | $moduleClass = $moduleNamespace . '\\' . basename($path) . 'Core'; |
| 90 | 92 | |
| 91 | - if (! is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 93 | + if (! is_a($moduleClass, ModuleCore::class, true)) { |
|
| 94 | + continue; |
|
| 95 | + } |
|
| 92 | 96 | |
| 93 | 97 | $ret->add($moduleClass); |
| 94 | 98 | } |
@@ -154,7 +158,9 @@ discard block |
||
| 154 | 158 | |
| 155 | 159 | $ret = []; |
| 156 | 160 | foreach ($installedModules as $module) { |
| 157 | - if (! $list = $module::$method(...$args)) continue; |
|
| 161 | + if (! $list = $module::$method(...$args)) { |
|
| 162 | + continue; |
|
| 163 | + } |
|
| 158 | 164 | |
| 159 | 165 | $ret = array_merge($ret, is_array($list)? $list: [$list]); |
| 160 | 166 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public static function isInstalled($classOrAlias) |
| 22 | 22 | { |
| 23 | - return self::getClass($classOrAlias, true)? 1: 0; |
|
| 23 | + return self::getClass($classOrAlias, true) ? 1 : 0; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public static function isAvailable($classOrAlias) |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @return string; |
| 36 | 36 | */ |
| 37 | 37 | public static function getClass($classOrAlias, $installedOnly = false) { |
| 38 | - $modules = $installedOnly? self::getInstalled(): self::getAll(); |
|
| 38 | + $modules = $installedOnly ? self::getInstalled() : self::getAll(); |
|
| 39 | 39 | |
| 40 | 40 | if (collect($modules)->contains($classOrAlias)) return $classOrAlias; |
| 41 | 41 | |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public static function getAll() |
| 69 | 69 | { |
| 70 | - return self::getCached('epesi-modules-available', function () { |
|
| 70 | + return self::getCached('epesi-modules-available', function() { |
|
| 71 | 71 | $modules = collect(); |
| 72 | - foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules()?: []) as $namespace => $path) { |
|
| 72 | + foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules() ?: []) as $namespace => $path) { |
|
| 73 | 73 | foreach (self::discoverModuleClasses($namespace, $path) as $moduleClass) { |
| 74 | 74 | $modules->add(['alias' => $moduleClass::alias(), 'class' => $moduleClass]); |
| 75 | 75 | } |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | protected static function discoverModuleClasses($namespace, $basePath) |
| 83 | 83 | { |
| 84 | 84 | $ret = collect(); |
| 85 | - foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
| 85 | + foreach (glob($basePath . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $path) { |
|
| 86 | 86 | $moduleNamespace = trim($namespace, '\\') . '\\' . basename($path); |
| 87 | 87 | |
| 88 | 88 | $ret = $ret->merge(self::discoverModuleClasses($moduleNamespace, $path)); |
| 89 | 89 | |
| 90 | 90 | $moduleClass = $moduleNamespace . '\\' . basename($path) . 'Core'; |
| 91 | 91 | |
| 92 | - if (! is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 92 | + if (!is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 93 | 93 | |
| 94 | 94 | $ret->add($moduleClass); |
| 95 | 95 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | protected static function getCached($key, \Closure $default) |
| 108 | 108 | { |
| 109 | - if (! Cache::has($key)) { |
|
| 109 | + if (!Cache::has($key)) { |
|
| 110 | 110 | Cache::forever($key, $default()); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public static function collect($method, $args = []) |
| 146 | 146 | { |
| 147 | - $args = is_array($args)? $args: [$args]; |
|
| 147 | + $args = is_array($args) ? $args : [$args]; |
|
| 148 | 148 | |
| 149 | 149 | $installedModules = self::getInstalled(); |
| 150 | 150 | |
| 151 | 151 | // if epesi is not installed fake having the system module to enable its functionality |
| 152 | - if (! $installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
| 152 | + if (!$installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
| 153 | 153 | $installedModules = collect([ |
| 154 | 154 | 'system' => \Epesi\Core\System\SystemCore::class |
| 155 | 155 | ]); |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $ret = []; |
| 159 | 159 | foreach ($installedModules as $module) { |
| 160 | - if (! $list = $module::$method(...$args)) continue; |
|
| 160 | + if (!$list = $module::$method(...$args)) continue; |
|
| 161 | 161 | |
| 162 | - $ret = array_merge($ret, is_array($list)? $list: [$list]); |
|
| 162 | + $ret = array_merge($ret, is_array($list) ? $list : [$list]); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | return $ret; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | return true; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 181 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 182 | 182 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | $parentModule = array_shift($unsatisfiedDependencies); |
| 238 | 238 | |
| 239 | 239 | if (self::$processing[$parentModule]?? false) { |
| 240 | - throw new Exception('Cross dependency: '. $parentModule); |
|
| 240 | + throw new Exception('Cross dependency: ' . $parentModule); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - if (! self::isAvailable($parentModule)) { |
|
| 243 | + if (!self::isAvailable($parentModule)) { |
|
| 244 | 244 | throw new Exception('Module not found: "' . $parentModule . '"'); |
| 245 | 245 | } |
| 246 | 246 | |
@@ -261,13 +261,13 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | public static function uninstall($classOrAlias) |
| 263 | 263 | { |
| 264 | - if (! self::isInstalled($classOrAlias)) { |
|
| 264 | + if (!self::isInstalled($classOrAlias)) { |
|
| 265 | 265 | print ('Module "' . $classOrAlias . '" is not installed!'); |
| 266 | 266 | |
| 267 | 267 | return true; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 270 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 271 | 271 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
| 272 | 272 | } |
| 273 | 273 | |