@@ -6,34 +6,34 @@ |
||
| 6 | 6 | |
| 7 | 7 | class PermissionsTableSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - /** |
|
| 17 | - * Insert the permissions related to permissions table. |
|
| 18 | - */ |
|
| 19 | - \DB::table('permissions')->insert( |
|
| 20 | - [ |
|
| 21 | - /** |
|
| 22 | - * Permissions model permissions. |
|
| 23 | - */ |
|
| 24 | - [ |
|
| 25 | - 'name' => 'index', |
|
| 26 | - 'model' => 'permission', |
|
| 27 | - 'created_at' => \DB::raw('NOW()'), |
|
| 28 | - 'updated_at' => \DB::raw('NOW()') |
|
| 29 | - ], |
|
| 30 | - [ |
|
| 31 | - 'name' => 'find', |
|
| 32 | - 'model' => 'permission', |
|
| 33 | - 'created_at' => \DB::raw('NOW()'), |
|
| 34 | - 'updated_at' => \DB::raw('NOW()') |
|
| 35 | - ], |
|
| 36 | - ] |
|
| 37 | - ); |
|
| 38 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + /** |
|
| 17 | + * Insert the permissions related to permissions table. |
|
| 18 | + */ |
|
| 19 | + \DB::table('permissions')->insert( |
|
| 20 | + [ |
|
| 21 | + /** |
|
| 22 | + * Permissions model permissions. |
|
| 23 | + */ |
|
| 24 | + [ |
|
| 25 | + 'name' => 'index', |
|
| 26 | + 'model' => 'permission', |
|
| 27 | + 'created_at' => \DB::raw('NOW()'), |
|
| 28 | + 'updated_at' => \DB::raw('NOW()') |
|
| 29 | + ], |
|
| 30 | + [ |
|
| 31 | + 'name' => 'find', |
|
| 32 | + 'model' => 'permission', |
|
| 33 | + 'created_at' => \DB::raw('NOW()'), |
|
| 34 | + 'updated_at' => \DB::raw('NOW()') |
|
| 35 | + ], |
|
| 36 | + ] |
|
| 37 | + ); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class PermissionsDatabaseSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $this->call(ClearDataSeeder::class); |
|
| 17 | - $this->call(PermissionsTableSeeder::class); |
|
| 18 | - $this->call(AssignRelationsSeeder::class); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $this->call(ClearDataSeeder::class); |
|
| 17 | + $this->call(PermissionsTableSeeder::class); |
|
| 18 | + $this->call(AssignRelationsSeeder::class); |
|
| 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 | - $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Assign the permissions to the admin group. |
|
| 20 | - */ |
|
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['permission'])->each(function ($permission) use ($adminGroupId) { |
|
| 22 | - \DB::table('groups_permissions')->insert( |
|
| 23 | - [ |
|
| 24 | - 'permission_id' => $permission->id, |
|
| 25 | - 'group_id' => $adminGroupId, |
|
| 26 | - 'created_at' => \DB::raw('NOW()'), |
|
| 27 | - 'updated_at' => \DB::raw('NOW()') |
|
| 28 | - ] |
|
| 29 | - ); |
|
| 30 | - }); |
|
| 31 | - } |
|
| 18 | + /** |
|
| 19 | + * Assign the permissions to the admin group. |
|
| 20 | + */ |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['permission'])->each(function ($permission) use ($adminGroupId) { |
|
| 22 | + \DB::table('groups_permissions')->insert( |
|
| 23 | + [ |
|
| 24 | + 'permission_id' => $permission->id, |
|
| 25 | + 'group_id' => $adminGroupId, |
|
| 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 group. |
| 20 | 20 | */ |
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['permission'])->each(function ($permission) use ($adminGroupId) { |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['permission'])->each(function($permission) use ($adminGroupId) { |
|
| 22 | 22 | \DB::table('groups_permissions')->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', ['permission']); |
|
| 17 | - \DB::table('groups_permissions')->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', ['permission']); |
|
| 17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | + $permissions->delete(); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -5,40 +5,40 @@ |
||
| 5 | 5 | |
| 6 | 6 | class Permissions extends Migration |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Run the migrations. |
|
| 10 | - * |
|
| 11 | - * @return void |
|
| 12 | - */ |
|
| 13 | - public function up() |
|
| 14 | - { |
|
| 15 | - Schema::create('permissions', function (Blueprint $table) { |
|
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('name', 100); |
|
| 18 | - $table->string('model', 100); |
|
| 19 | - $table->softDeletes(); |
|
| 20 | - $table->timestamps(); |
|
| 21 | - $table->unique(array('name', 'model')); |
|
| 22 | - }); |
|
| 23 | - Schema::create('groups_permissions', function (Blueprint $table) { |
|
| 24 | - $table->increments('id'); |
|
| 25 | - $table->integer('group_id'); |
|
| 26 | - $table->integer('permission_id'); |
|
| 27 | - $table->softDeletes(); |
|
| 28 | - $table->timestamps(); |
|
| 8 | + /** |
|
| 9 | + * Run the migrations. |
|
| 10 | + * |
|
| 11 | + * @return void |
|
| 12 | + */ |
|
| 13 | + public function up() |
|
| 14 | + { |
|
| 15 | + Schema::create('permissions', function (Blueprint $table) { |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name', 100); |
|
| 18 | + $table->string('model', 100); |
|
| 19 | + $table->softDeletes(); |
|
| 20 | + $table->timestamps(); |
|
| 21 | + $table->unique(array('name', 'model')); |
|
| 22 | + }); |
|
| 23 | + Schema::create('groups_permissions', function (Blueprint $table) { |
|
| 24 | + $table->increments('id'); |
|
| 25 | + $table->integer('group_id'); |
|
| 26 | + $table->integer('permission_id'); |
|
| 27 | + $table->softDeletes(); |
|
| 28 | + $table->timestamps(); |
|
| 29 | 29 | |
| 30 | - $table->index(['group_id']); |
|
| 31 | - }); |
|
| 32 | - } |
|
| 30 | + $table->index(['group_id']); |
|
| 31 | + }); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Reverse the migrations. |
|
| 36 | - * |
|
| 37 | - * @return void |
|
| 38 | - */ |
|
| 39 | - public function down() |
|
| 40 | - { |
|
| 41 | - Schema::dropIfExists('permissions'); |
|
| 42 | - Schema::dropIfExists('groups_permissions'); |
|
| 43 | - } |
|
| 34 | + /** |
|
| 35 | + * Reverse the migrations. |
|
| 36 | + * |
|
| 37 | + * @return void |
|
| 38 | + */ |
|
| 39 | + public function down() |
|
| 40 | + { |
|
| 41 | + Schema::dropIfExists('permissions'); |
|
| 42 | + Schema::dropIfExists('groups_permissions'); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('permissions', function (Blueprint $table) { |
|
| 15 | + Schema::create('permissions', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->string('name', 100); |
| 18 | 18 | $table->string('model', 100); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $table->timestamps(); |
| 21 | 21 | $table->unique(array('name', 'model')); |
| 22 | 22 | }); |
| 23 | - Schema::create('groups_permissions', function (Blueprint $table) { |
|
| 23 | + Schema::create('groups_permissions', function(Blueprint $table) { |
|
| 24 | 24 | $table->increments('id'); |
| 25 | 25 | $table->integer('group_id'); |
| 26 | 26 | $table->integer('permission_id'); |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | |
| 8 | 8 | class AclPermission extends JsonResource |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Transform the resource into an array. |
|
| 12 | - * |
|
| 13 | - * @param Request $request |
|
| 14 | - * @return array |
|
| 15 | - */ |
|
| 16 | - public function toArray($request) |
|
| 17 | - { |
|
| 18 | - if (! $this->resource) { |
|
| 19 | - return []; |
|
| 20 | - } |
|
| 10 | + /** |
|
| 11 | + * Transform the resource into an array. |
|
| 12 | + * |
|
| 13 | + * @param Request $request |
|
| 14 | + * @return array |
|
| 15 | + */ |
|
| 16 | + public function toArray($request) |
|
| 17 | + { |
|
| 18 | + if (! $this->resource) { |
|
| 19 | + return []; |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - return [ |
|
| 23 | - 'id' => $this->id, |
|
| 24 | - 'name' => $this->name, |
|
| 25 | - 'groups' => GroupResource::collection($this->whenLoaded('groups')), |
|
| 26 | - 'created_at' => $this->created_at, |
|
| 27 | - 'updated_at' => $this->updated_at, |
|
| 28 | - ]; |
|
| 29 | - } |
|
| 22 | + return [ |
|
| 23 | + 'id' => $this->id, |
|
| 24 | + 'name' => $this->name, |
|
| 25 | + 'groups' => GroupResource::collection($this->whenLoaded('groups')), |
|
| 26 | + 'created_at' => $this->created_at, |
|
| 27 | + 'updated_at' => $this->updated_at, |
|
| 28 | + ]; |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function toArray($request) |
| 17 | 17 | { |
| 18 | - if (! $this->resource) { |
|
| 18 | + if ( ! $this->resource) { |
|
| 19 | 19 | return []; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -8,15 +8,15 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PermissionController extends BaseApiController |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * Init new object. |
|
| 13 | - * |
|
| 14 | - * @param PermissionRepository $repo |
|
| 15 | - * @param CoreConfig $config |
|
| 16 | - * @return void |
|
| 17 | - */ |
|
| 18 | - public function __construct(PermissionRepository $repo, CoreConfig $config) |
|
| 19 | - { |
|
| 20 | - parent::__construct($repo, $config, 'App\Modules\Permissions\Http\Resources\AclPermission'); |
|
| 21 | - } |
|
| 11 | + /** |
|
| 12 | + * Init new object. |
|
| 13 | + * |
|
| 14 | + * @param PermissionRepository $repo |
|
| 15 | + * @param CoreConfig $config |
|
| 16 | + * @return void |
|
| 17 | + */ |
|
| 18 | + public function __construct(PermissionRepository $repo, CoreConfig $config) |
|
| 19 | + { |
|
| 20 | + parent::__construct($repo, $config, 'App\Modules\Permissions\Http\Resources\AclPermission'); |
|
| 21 | + } |
|
| 22 | 22 | } |
@@ -6,28 +6,28 @@ |
||
| 6 | 6 | |
| 7 | 7 | class OauthClient extends Client |
| 8 | 8 | { |
| 9 | - protected $dates = ['created_at', 'updated_at']; |
|
| 10 | - protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
| 11 | - public $searchable = ['name']; |
|
| 9 | + protected $dates = ['created_at', 'updated_at']; |
|
| 10 | + protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
| 11 | + public $searchable = ['name']; |
|
| 12 | 12 | |
| 13 | - public function getCreatedAtAttribute($value) |
|
| 14 | - { |
|
| 15 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 16 | - } |
|
| 13 | + public function getCreatedAtAttribute($value) |
|
| 14 | + { |
|
| 15 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function getUpdatedAtAttribute($value) |
|
| 19 | - { |
|
| 20 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 21 | - } |
|
| 18 | + public function getUpdatedAtAttribute($value) |
|
| 19 | + { |
|
| 20 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function user() |
|
| 24 | - { |
|
| 25 | - return $this->belongsTo('App\Modules\Users\AclUser'); |
|
| 26 | - } |
|
| 23 | + public function user() |
|
| 24 | + { |
|
| 25 | + return $this->belongsTo('App\Modules\Users\AclUser'); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public static function boot() |
|
| 29 | - { |
|
| 30 | - parent::boot(); |
|
| 31 | - OauthClient::observe(\App::make('App\Modules\OauthClients\ModelObservers\OauthClientObserver')); |
|
| 32 | - } |
|
| 28 | + public static function boot() |
|
| 29 | + { |
|
| 30 | + parent::boot(); |
|
| 31 | + OauthClient::observe(\App::make('App\Modules\OauthClients\ModelObservers\OauthClientObserver')); |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -5,38 +5,38 @@ |
||
| 5 | 5 | |
| 6 | 6 | class OauthClientRepository extends BaseRepository |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Init new object. |
|
| 10 | - * |
|
| 11 | - * @param OauthClient $model |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function __construct(OauthClient $model) |
|
| 15 | - { |
|
| 16 | - parent::__construct($model); |
|
| 17 | - } |
|
| 8 | + /** |
|
| 9 | + * Init new object. |
|
| 10 | + * |
|
| 11 | + * @param OauthClient $model |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function __construct(OauthClient $model) |
|
| 15 | + { |
|
| 16 | + parent::__construct($model); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Revoke the given client. |
|
| 21 | - * |
|
| 22 | - * @param integer $clientId |
|
| 23 | - * @return void |
|
| 24 | - */ |
|
| 25 | - public function revoke($clientId) |
|
| 26 | - { |
|
| 27 | - $client = $this->find($clientId); |
|
| 28 | - $client->tokens()->update(['revoked' => true]); |
|
| 29 | - $this->save(['id'=> $clientId, 'revoked' => true]); |
|
| 30 | - } |
|
| 19 | + /** |
|
| 20 | + * Revoke the given client. |
|
| 21 | + * |
|
| 22 | + * @param integer $clientId |
|
| 23 | + * @return void |
|
| 24 | + */ |
|
| 25 | + public function revoke($clientId) |
|
| 26 | + { |
|
| 27 | + $client = $this->find($clientId); |
|
| 28 | + $client->tokens()->update(['revoked' => true]); |
|
| 29 | + $this->save(['id'=> $clientId, 'revoked' => true]); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Un revoke the given client. |
|
| 34 | - * |
|
| 35 | - * @param integer $clientId |
|
| 36 | - * @return void |
|
| 37 | - */ |
|
| 38 | - public function unRevoke($clientId) |
|
| 39 | - { |
|
| 40 | - $this->save(['id'=> $clientId, 'revoked' => false]); |
|
| 41 | - } |
|
| 32 | + /** |
|
| 33 | + * Un revoke the given client. |
|
| 34 | + * |
|
| 35 | + * @param integer $clientId |
|
| 36 | + * @return void |
|
| 37 | + */ |
|
| 38 | + public function unRevoke($clientId) |
|
| 39 | + { |
|
| 40 | + $this->save(['id'=> $clientId, 'revoked' => false]); |
|
| 41 | + } |
|
| 42 | 42 | } |