Completed
Push — master ( 8df45b...9d0042 )
by Sherif
02:28 queued 11s
created
src/Modules/Groups/Database/Seeds/AssignRelationsSeeder.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
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', ['group'])->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', ['group'])->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
 }
Please login to merge, or discard this patch.
src/Modules/Groups/Database/Seeds/GroupsDatabaseSeeder.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
6 6
 
7 7
 class GroupsDatabaseSeeder 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(GroupsTableSeeder::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(GroupsTableSeeder::class);
18
+		$this->call(AssignRelationsSeeder::class);
19
+	}
20 20
 }
Please login to merge, or discard this patch.
src/Modules/Groups/Database/Seeds/ClearDataSeeder.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
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', ['group']);
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', ['group']);
17
+		\DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete();
18
+		$permissions->delete();
19
+	}
20 20
 }
Please login to merge, or discard this patch.
src/Modules/Groups/Database/Migrations/2015_12_22_145819_groups.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -5,66 +5,66 @@
 block discarded – undo
5 5
 
6 6
 class Groups extends Migration
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function up()
14
-    {
15
-        Schema::create('groups', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name', 100)->unique();
18
-            $table->softDeletes();
19
-            $table->timestamps();
20
-        });
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('groups', function (Blueprint $table) {
16
+			$table->increments('id');
17
+			$table->string('name', 100)->unique();
18
+			$table->softDeletes();
19
+			$table->timestamps();
20
+		});
21 21
         
22
-        Schema::create('users_groups', function (Blueprint $table) {
23
-            $table->increments('id');
24
-            $table->integer('user_id');
25
-            $table->integer('group_id');
26
-            $table->softDeletes();
27
-            $table->timestamps();
22
+		Schema::create('users_groups', function (Blueprint $table) {
23
+			$table->increments('id');
24
+			$table->integer('user_id');
25
+			$table->integer('group_id');
26
+			$table->softDeletes();
27
+			$table->timestamps();
28 28
 
29
-            $table->index(['user_id']);
30
-        });
29
+			$table->index(['user_id']);
30
+		});
31 31
         
32
-        /**
33
-         * Create Default groups.
34
-         */
35
-        \DB::table('groups')->insert(
36
-            [
37
-                [
38
-                    'name'       => 'Admin',
39
-                    'created_at' => \DB::raw('NOW()'),
40
-                    'updated_at' => \DB::raw('NOW()')
41
-                ]
42
-            ]
43
-        );
32
+		/**
33
+		 * Create Default groups.
34
+		 */
35
+		\DB::table('groups')->insert(
36
+			[
37
+				[
38
+					'name'       => 'Admin',
39
+					'created_at' => \DB::raw('NOW()'),
40
+					'updated_at' => \DB::raw('NOW()')
41
+				]
42
+			]
43
+		);
44 44
         
45
-        /**
46
-         * Assign default users to admin groups.
47
-         */
48
-        $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id;
49
-        $adminUserId  = \DB::table('users')->where('email', '[email protected]')->select('id')->first()->id;
50
-        \DB::table('users_groups')->insert(
51
-            [
52
-            'user_id'    => $adminUserId,
53
-            'group_id'   => $adminGroupId,
54
-            'created_at' => \DB::raw('NOW()'),
55
-            'updated_at' => \DB::raw('NOW()')
56
-            ]
57
-        );
58
-    }
45
+		/**
46
+		 * Assign default users to admin groups.
47
+		 */
48
+		$adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id;
49
+		$adminUserId  = \DB::table('users')->where('email', '[email protected]')->select('id')->first()->id;
50
+		\DB::table('users_groups')->insert(
51
+			[
52
+			'user_id'    => $adminUserId,
53
+			'group_id'   => $adminGroupId,
54
+			'created_at' => \DB::raw('NOW()'),
55
+			'updated_at' => \DB::raw('NOW()')
56
+			]
57
+		);
58
+	}
59 59
 
60
-    /**
61
-     * Reverse the migrations.
62
-     *
63
-     * @return void
64
-     */
65
-    public function down()
66
-    {
67
-        Schema::dropIfExists('groups');
68
-        Schema::dropIfExists('users_groups');
69
-    }
60
+	/**
61
+	 * Reverse the migrations.
62
+	 *
63
+	 * @return void
64
+	 */
65
+	public function down()
66
+	{
67
+		Schema::dropIfExists('groups');
68
+		Schema::dropIfExists('users_groups');
69
+	}
70 70
 }
Please login to merge, or discard this patch.
src/Modules/Groups/AclGroup.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 class AclGroup extends Model
7 7
 {
8 8
 
9
-    use SoftDeletes;
10
-    protected $table    = 'groups';
11
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
12
-    protected $hidden   = ['deleted_at'];
13
-    protected $guarded  = ['id'];
14
-    protected $fillable = ['name'];
15
-    public $searchable  = ['name'];
16
-
17
-    public function getCreatedAtAttribute($value)
18
-    {
19
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
20
-    }
21
-
22
-    public function getUpdatedAtAttribute($value)
23
-    {
24
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
25
-    }
26
-
27
-    public function getDeletedAtAttribute($value)
28
-    {
29
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
30
-    }
31
-
32
-    public function users()
33
-    {
34
-        return $this->belongsToMany('App\Modules\Users\AclUser', 'users_groups', 'group_id', 'user_id')->whereNull('users_groups.deleted_at')->withTimestamps();
35
-    }
36
-
37
-    public function permissions()
38
-    {
39
-        return $this->belongsToMany('App\Modules\Permissions\AclPermission', 'groups_permissions', 'group_id', 'permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
40
-    }
41
-
42
-    public static function boot()
43
-    {
44
-        parent::boot();
45
-        AclGroup::observe(\App::make('App\Modules\Groups\ModelObservers\AclGroupObserver'));
46
-    }
9
+	use SoftDeletes;
10
+	protected $table    = 'groups';
11
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
12
+	protected $hidden   = ['deleted_at'];
13
+	protected $guarded  = ['id'];
14
+	protected $fillable = ['name'];
15
+	public $searchable  = ['name'];
16
+
17
+	public function getCreatedAtAttribute($value)
18
+	{
19
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
20
+	}
21
+
22
+	public function getUpdatedAtAttribute($value)
23
+	{
24
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
25
+	}
26
+
27
+	public function getDeletedAtAttribute($value)
28
+	{
29
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
30
+	}
31
+
32
+	public function users()
33
+	{
34
+		return $this->belongsToMany('App\Modules\Users\AclUser', 'users_groups', 'group_id', 'user_id')->whereNull('users_groups.deleted_at')->withTimestamps();
35
+	}
36
+
37
+	public function permissions()
38
+	{
39
+		return $this->belongsToMany('App\Modules\Permissions\AclPermission', 'groups_permissions', 'group_id', 'permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
40
+	}
41
+
42
+	public static function boot()
43
+	{
44
+		parent::boot();
45
+		AclGroup::observe(\App::make('App\Modules\Groups\ModelObservers\AclGroupObserver'));
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Modules/Groups/Http/Resources/AclGroup.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@
 block discarded – undo
8 8
 
9 9
 class AclGroup extends JsonResource
10 10
 {
11
-    /**
12
-     * Transform the resource into an array.
13
-     *
14
-     * @param Request $request
15
-     * @return array
16
-     */
17
-    public function toArray($request)
18
-    {
19
-        if (! $this->resource) {
20
-            return [];
21
-        }
11
+	/**
12
+	 * Transform the resource into an array.
13
+	 *
14
+	 * @param Request $request
15
+	 * @return array
16
+	 */
17
+	public function toArray($request)
18
+	{
19
+		if (! $this->resource) {
20
+			return [];
21
+		}
22 22
 
23
-        return [
24
-            'id' => $this->id,
25
-            'name' => $this->name,
26
-            'users' => UserResource::collection($this->whenLoaded('users')),
27
-            'permissions' => PermissionResource::collection($this->whenLoaded('permissions')),
28
-            'created_at' => $this->created_at,
29
-            'updated_at' => $this->updated_at,
30
-        ];
31
-    }
23
+		return [
24
+			'id' => $this->id,
25
+			'name' => $this->name,
26
+			'users' => UserResource::collection($this->whenLoaded('users')),
27
+			'permissions' => PermissionResource::collection($this->whenLoaded('permissions')),
28
+			'created_at' => $this->created_at,
29
+			'updated_at' => $this->updated_at,
30
+		];
31
+	}
32 32
 }
Please login to merge, or discard this patch.
src/Modules/Groups/Http/Controllers/GroupController.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -11,48 +11,48 @@
 block discarded – undo
11 11
 
12 12
 class GroupController extends BaseApiController
13 13
 {
14
-    /**
15
-     * Init new object.
16
-     *
17
-     * @param   GroupRepository $repo
18
-     * @param   CoreConfig      $config
19
-     * @return  void
20
-     */
21
-    public function __construct(GroupRepository $repo, CoreConfig $config)
22
-    {
23
-        parent::__construct($repo, $config, 'App\Modules\Groups\Http\Resources\AclGroup');
24
-    }
14
+	/**
15
+	 * Init new object.
16
+	 *
17
+	 * @param   GroupRepository $repo
18
+	 * @param   CoreConfig      $config
19
+	 * @return  void
20
+	 */
21
+	public function __construct(GroupRepository $repo, CoreConfig $config)
22
+	{
23
+		parent::__construct($repo, $config, 'App\Modules\Groups\Http\Resources\AclGroup');
24
+	}
25 25
 
26
-    /**
27
-     * Insert the given model to storage.
28
-     *
29
-     * @param InsertGroup $request
30
-     * @return \Illuminate\Http\Response
31
-     */
32
-    public function insert(InsertGroup $request)
33
-    {
34
-        return new $this->modelResource($this->repo->save($request->all()));
35
-    }
26
+	/**
27
+	 * Insert the given model to storage.
28
+	 *
29
+	 * @param InsertGroup $request
30
+	 * @return \Illuminate\Http\Response
31
+	 */
32
+	public function insert(InsertGroup $request)
33
+	{
34
+		return new $this->modelResource($this->repo->save($request->all()));
35
+	}
36 36
 
37
-    /**
38
-     * Update the given model to storage.
39
-     *
40
-     * @param UpdateGroup $request
41
-     * @return \Illuminate\Http\Response
42
-     */
43
-    public function update(UpdateGroup $request)
44
-    {
45
-        return new $this->modelResource($this->repo->save($request->all()));
46
-    }
37
+	/**
38
+	 * Update the given model to storage.
39
+	 *
40
+	 * @param UpdateGroup $request
41
+	 * @return \Illuminate\Http\Response
42
+	 */
43
+	public function update(UpdateGroup $request)
44
+	{
45
+		return new $this->modelResource($this->repo->save($request->all()));
46
+	}
47 47
 
48
-    /**
49
-     * Handle an assign permissions to group request.
50
-     *
51
-     * @param  AssignPermissions $request
52
-     * @return \Illuminate\Http\Response
53
-     */
54
-    public function assignPermissions(AssignPermissions $request)
55
-    {
56
-        return new $this->modelResource($this->repo->assignPermissions($request->get('group_id'), $request->get('permission_ids')));
57
-    }
48
+	/**
49
+	 * Handle an assign permissions to group request.
50
+	 *
51
+	 * @param  AssignPermissions $request
52
+	 * @return \Illuminate\Http\Response
53
+	 */
54
+	public function assignPermissions(AssignPermissions $request)
55
+	{
56
+		return new $this->modelResource($this->repo->assignPermissions($request->get('group_id'), $request->get('permission_ids')));
57
+	}
58 58
 }
Please login to merge, or discard this patch.
src/Modules/Groups/Http/Requests/AssignPermissions.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class AssignPermissions extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'permission_ids' => 'required|exists:permissions,id',
28
-            'group_id'       => 'required|array|exists:groups,id'
29
-        ];
30
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'permission_ids' => 'required|exists:permissions,id',
28
+			'group_id'       => 'required|array|exists:groups,id'
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/Groups/Http/Requests/UpdateGroup.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class UpdateGroup extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'id'   => 'required|exists:groups,id',
28
-            'name' => 'required|string|max:100|unique:groups,name,'.$this->get('id')
29
-        ];
30
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'id'   => 'required|exists:groups,id',
28
+			'name' => 'required|string|max:100|unique:groups,name,'.$this->get('id')
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.