Completed
Push — master ( 244647...7f4033 )
by Sherif
03:03
created
src/Modules/Acl/Http/Controllers/UsersController.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace App\Modules\Acl\Http\Controllers;
3 3
 
4
-use Illuminate\Foundation\Http\FormRequest;
5 4
 use App\Modules\Core\Http\Controllers\BaseApiController;
6 5
 use Illuminate\Http\Request;
7 6
 
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -7,108 +7,108 @@
 block discarded – undo
7 7
 
8 8
 class UsersController extends BaseApiController
9 9
 {
10
-    /**
11
-     * The name of the model that is used by the base api controller 
12
-     * to preform actions like (add, edit ... etc).
13
-     * @var string
14
-     */
15
-    protected $model               = 'users';
10
+	/**
11
+	 * The name of the model that is used by the base api controller 
12
+	 * to preform actions like (add, edit ... etc).
13
+	 * @var string
14
+	 */
15
+	protected $model               = 'users';
16 16
 
17
-    /**
18
-     * List of all route actions that the base api controller
19
-     * will skip permissions check for them.
20
-     * @var array
21
-     */
22
-    protected $skipPermissionCheck = ['account', 'logout'];
17
+	/**
18
+	 * List of all route actions that the base api controller
19
+	 * will skip permissions check for them.
20
+	 * @var array
21
+	 */
22
+	protected $skipPermissionCheck = ['account', 'logout'];
23 23
 
24
-    /**
25
-     * List of all route actions that the base api controller
26
-     * will skip login check for them.
27
-     * @var array
28
-     */
29
-    protected $skipLoginCheck = ['login', 'register'];
24
+	/**
25
+	 * List of all route actions that the base api controller
26
+	 * will skip login check for them.
27
+	 * @var array
28
+	 */
29
+	protected $skipLoginCheck = ['login', 'register'];
30 30
 
31
-    /**
32
-     * The validations rules used by the base api controller
33
-     * to check before add.
34
-     * @var array
35
-     */
36
-    protected $validationRules  = [
37
-    'email'    => 'required|email|unique:users,email,{id}',
38
-    'password' => 'min:6'
39
-    ];
31
+	/**
32
+	 * The validations rules used by the base api controller
33
+	 * to check before add.
34
+	 * @var array
35
+	 */
36
+	protected $validationRules  = [
37
+	'email'    => 'required|email|unique:users,email,{id}',
38
+	'password' => 'min:6'
39
+	];
40 40
 
41
-    /**
42
-     * Return the logged in user account.
43
-     * 
44
-     * @return object
45
-     */
46
-    public function getAccount()
47
-    {
48
-       $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
49
-       return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find(\JWTAuth::parseToken()->authenticate()->id, $relations), 200);
50
-    }
41
+	/**
42
+	 * Return the logged in user account.
43
+	 * 
44
+	 * @return object
45
+	 */
46
+	public function getAccount()
47
+	{
48
+	   $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
49
+	   return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find(\JWTAuth::parseToken()->authenticate()->id, $relations), 200);
50
+	}
51 51
 
52
-    /**
53
-     * Logout the user.
54
-     * 
55
-     * @return void
56
-     */
57
-    public function getLogout()
58
-    {
59
-        return \Response::json(\JWTAuth::invalidate(\JWTAuth::getToken()), 200);
60
-    }
52
+	/**
53
+	 * Logout the user.
54
+	 * 
55
+	 * @return void
56
+	 */
57
+	public function getLogout()
58
+	{
59
+		return \Response::json(\JWTAuth::invalidate(\JWTAuth::getToken()), 200);
60
+	}
61 61
 
62
-    /**
63
-     * Handle a registration request.
64
-     *
65
-     * @param  \Illuminate\Http\Request  $request
66
-     * @return \Illuminate\Http\Response
67
-     */
68
-    public function postRegister(Request $request)
69
-    {
70
-        $this->validate($request, ['email' => 'required|email|unique:users,email,{id}', 'password' => 'required|min:6']);
62
+	/**
63
+	 * Handle a registration request.
64
+	 *
65
+	 * @param  \Illuminate\Http\Request  $request
66
+	 * @return \Illuminate\Http\Response
67
+	 */
68
+	public function postRegister(Request $request)
69
+	{
70
+		$this->validate($request, ['email' => 'required|email|unique:users,email,{id}', 'password' => 'required|min:6']);
71 71
 
72
-        $credentials = $request->only('email', 'password');
73
-        $token       = \JWTAuth::fromUser(\Core::users()->model->create($credentials));
74
-        return \Response::json($token, 200);
75
-    }
72
+		$credentials = $request->only('email', 'password');
73
+		$token       = \JWTAuth::fromUser(\Core::users()->model->create($credentials));
74
+		return \Response::json($token, 200);
75
+	}
76 76
 
77
-    /**
78
-     * Handle a login request to the application.
79
-     *
80
-     * @param  \Illuminate\Http\Request  $request
81
-     * @return \Illuminate\Http\Response
82
-     */
83
-    public function postLogin(Request $request)
84
-    {
85
-        $credentials = $request->only('email', 'password');
77
+	/**
78
+	 * Handle a login request to the application.
79
+	 *
80
+	 * @param  \Illuminate\Http\Request  $request
81
+	 * @return \Illuminate\Http\Response
82
+	 */
83
+	public function postLogin(Request $request)
84
+	{
85
+		$credentials = $request->only('email', 'password');
86 86
 
87
-        if ($token = \JWTAuth::attempt($credentials))
88
-        {
89
-            $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
90
-            return \Response::json($token, 200);
91
-        }
92
-        else
93
-        {
94
-            $error = \ErrorHandler::loginFailed();
95
-            abort($error['status'], $error['message']);
96
-        }
97
-    }
87
+		if ($token = \JWTAuth::attempt($credentials))
88
+		{
89
+			$relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
90
+			return \Response::json($token, 200);
91
+		}
92
+		else
93
+		{
94
+			$error = \ErrorHandler::loginFailed();
95
+			abort($error['status'], $error['message']);
96
+		}
97
+	}
98 98
 
99
-    /**
100
-     * Handle an assign groups to user request.
101
-     *
102
-     * @param  \Illuminate\Http\Request  $request
103
-     * @return \Illuminate\Http\Response
104
-     */
105
-    public function postAssigngroups(Request $request)
106
-    {
107
-        $this->validate($request, [
108
-            'group_ids' => 'required|exists:groups,id', 
109
-            'user_id'   => 'required|exists:users,id'
110
-            ]);
99
+	/**
100
+	 * Handle an assign groups to user request.
101
+	 *
102
+	 * @param  \Illuminate\Http\Request  $request
103
+	 * @return \Illuminate\Http\Response
104
+	 */
105
+	public function postAssigngroups(Request $request)
106
+	{
107
+		$this->validate($request, [
108
+			'group_ids' => 'required|exists:groups,id', 
109
+			'user_id'   => 'required|exists:users,id'
110
+			]);
111 111
 
112
-        return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200);
113
-    }
112
+		return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200);
113
+	}
114 114
 }
Please login to merge, or discard this patch.
src/Modules/Acl/Repositories/UserRepository.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,6 +61,6 @@
 block discarded – undo
61 61
 			$user->groups()->attach($group_ids);
62 62
 		});
63 63
 
64
-        return \Core::users()->find($user_id);
64
+		return \Core::users()->find($user_id);
65 65
 	}
66 66
 }
Please login to merge, or discard this patch.
src/Modules/Acl/Repositories/GroupRepository.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,6 +29,6 @@
 block discarded – undo
29 29
 			$group->permissions()->attach($permission_ids);
30 30
 		});
31 31
 
32
-        return \Core::groups()->find($group_id);
32
+		return \Core::groups()->find($group_id);
33 33
 	}
34 34
 }
Please login to merge, or discard this patch.
src/Modules/Acl/Http/Controllers/GroupsController.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@
 block discarded – undo
8 8
 
9 9
 class GroupsController extends BaseApiController
10 10
 {
11
-    /**
12
-     * The name of the model that is used by the base api controller 
13
-     * to preform actions like (add, edit ... etc).
14
-     * @var string
15
-     */
16
-    protected $model               = 'groups';
11
+	/**
12
+	 * The name of the model that is used by the base api controller 
13
+	 * to preform actions like (add, edit ... etc).
14
+	 * @var string
15
+	 */
16
+	protected $model               = 'groups';
17 17
 
18
-    /**
19
-     * The validations rules used by the base api controller
20
-     * to check before add.
21
-     * @var array
22
-     */
23
-    protected $validationRules  = [
24
-    'name' => 'required|string|max:100|unique:groups,name,{id}'
25
-    ];
18
+	/**
19
+	 * The validations rules used by the base api controller
20
+	 * to check before add.
21
+	 * @var array
22
+	 */
23
+	protected $validationRules  = [
24
+	'name' => 'required|string|max:100|unique:groups,name,{id}'
25
+	];
26 26
 
27
-    /**
28
-     * Handle an assign permissions to group request.
29
-     *
30
-     * @param  \Illuminate\Http\Request  $request
31
-     * @return \Illuminate\Http\Response
32
-     */
33
-    public function postAssignpermissions(Request $request)
34
-    {
35
-        $this->validate($request, [
36
-            'permission_ids' => 'required|exists:permissions,id', 
37
-            'group_id'       => 'required|exists:groups,id'
38
-            ]);
27
+	/**
28
+	 * Handle an assign permissions to group request.
29
+	 *
30
+	 * @param  \Illuminate\Http\Request  $request
31
+	 * @return \Illuminate\Http\Response
32
+	 */
33
+	public function postAssignpermissions(Request $request)
34
+	{
35
+		$this->validate($request, [
36
+			'permission_ids' => 'required|exists:permissions,id', 
37
+			'group_id'       => 'required|exists:groups,id'
38
+			]);
39 39
 
40
-        return \Response::json(\Core::groups()->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200);
41
-    }
40
+		return \Response::json(\Core::groups()->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
src/Modules/Acl/Http/Controllers/PermissionsController.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
 
8 8
 class PermissionsController extends BaseApiController
9 9
 {
10
-    /**
11
-     * The name of the model that is used by the base api controller 
12
-     * to preform actions like (add, edit ... etc).
13
-     * @var string
14
-     */
15
-    protected $model = 'permissions';
10
+	/**
11
+	 * The name of the model that is used by the base api controller 
12
+	 * to preform actions like (add, edit ... etc).
13
+	 * @var string
14
+	 */
15
+	protected $model = 'permissions';
16 16
 }
Please login to merge, or discard this patch.
src/Modules/Acl/Database/Migrations/2015_12_20_124153_users.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		Schema::create('users', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('first_name',100)->nullable();
18
-            $table->string('last_name',100)->nullable();
19
-            $table->string('user_name',100)->nullable();
20
-            $table->text('address')->nullable();
21
-            $table->string('email')->unique();
22
-            $table->string('password', 60);
23
-            $table->softDeletes();
24
-            $table->rememberToken();
25
-            $table->timestamps();
26
-        });
16
+			$table->increments('id');
17
+			$table->string('first_name',100)->nullable();
18
+			$table->string('last_name',100)->nullable();
19
+			$table->string('user_name',100)->nullable();
20
+			$table->text('address')->nullable();
21
+			$table->string('email')->unique();
22
+			$table->string('password', 60);
23
+			$table->softDeletes();
24
+			$table->rememberToken();
25
+			$table->timestamps();
26
+		});
27 27
 	}
28 28
 
29 29
 	/**
Please login to merge, or discard this patch.
src/Modules/Acl/Database/Migrations/2016_01_05_130506_permissions.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,21 +12,21 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 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
-        });
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
+		});
30 30
 	}
31 31
 
32 32
 	/**
Please login to merge, or discard this patch.
src/Modules/Acl/Database/Migrations/2015_12_22_145819_groups.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		Schema::create('groups', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name',100)->unique();
18
-            $table->softDeletes();
19
-            $table->timestamps();
20
-        });
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();
28
-        });
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
+		});
29 29
 	}
30 30
 
31 31
 	/**
Please login to merge, or discard this patch.
src/Modules/Core/Interfaces/RepositoryInterface.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -3,127 +3,127 @@
 block discarded – undo
3 3
 interface RepositoryInterface
4 4
 {
5 5
 	/**
6
-     * Fetch all records with relations from the storage.
7
-     * 
8
-     * @param  array  $relations
9
-     * @param  array   $sortBy
10
-     * @param  array   $desc
11
-     * @param  array  $columns
12
-     * @return collection
13
-     */
6
+	 * Fetch all records with relations from the storage.
7
+	 * 
8
+	 * @param  array  $relations
9
+	 * @param  array   $sortBy
10
+	 * @param  array   $desc
11
+	 * @param  array  $columns
12
+	 * @return collection
13
+	 */
14 14
 	public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
15 15
  	
16
-    /**
17
-     * Fetch all records with relations from storage in pages 
18
-     * that matche the given query.
19
-     * 
20
-     * @param  string  $query
21
-     * @param  integer $perPage
22
-     * @param  array   $relations
23
-     * @param  array   $sortBy
24
-     * @param  array   $desc
25
-     * @param  array   $columns
26
-     * @return collection
27
-     */
28
-    public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
16
+	/**
17
+	 * Fetch all records with relations from storage in pages 
18
+	 * that matche the given query.
19
+	 * 
20
+	 * @param  string  $query
21
+	 * @param  integer $perPage
22
+	 * @param  array   $relations
23
+	 * @param  array   $sortBy
24
+	 * @param  array   $desc
25
+	 * @param  array   $columns
26
+	 * @return collection
27
+	 */
28
+	public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
29 29
 
30 30
 	/**
31
-     * Fetch all records with relations from storage in pages.
32
-     * 
33
-     * @param  integer $perPage
34
-     * @param  array   $relations
35
-     * @param  array   $sortBy
36
-     * @param  array   $desc
37
-     * @param  array   $columns
38
-     * @return collection
39
-     */
40
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
31
+	 * Fetch all records with relations from storage in pages.
32
+	 * 
33
+	 * @param  integer $perPage
34
+	 * @param  array   $relations
35
+	 * @param  array   $sortBy
36
+	 * @param  array   $desc
37
+	 * @param  array   $columns
38
+	 * @return collection
39
+	 */
40
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
41 41
  	
42 42
 	/**
43
-     * Fetch all records with relations based on
44
-     * the given condition from storage in pages.
45
-     * 
46
-     * @param  array   $conditions array of conditions
47
-     * @param  integer $perPage
48
-     * @param  array   $relations
49
-     * @param  array   $sortBy
50
-     * @param  array   $desc
51
-     * @param  array   $columns
52
-     * @return collection
53
-     */
54
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
43
+	 * Fetch all records with relations based on
44
+	 * the given condition from storage in pages.
45
+	 * 
46
+	 * @param  array   $conditions array of conditions
47
+	 * @param  integer $perPage
48
+	 * @param  array   $relations
49
+	 * @param  array   $sortBy
50
+	 * @param  array   $desc
51
+	 * @param  array   $columns
52
+	 * @return collection
53
+	 */
54
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
55 55
 
56
-     /**
57
-     * Save the given model/models to the storage.
58
-     * 
59
-     * @param  array   $data
60
-     * @param  boolean $saveLog
61
-     * @return object
62
-     */
63
-    public function save(array $data, $saveLog = true);
56
+	 /**
57
+	  * Save the given model/models to the storage.
58
+	  * 
59
+	  * @param  array   $data
60
+	  * @param  boolean $saveLog
61
+	  * @return object
62
+	  */
63
+	public function save(array $data, $saveLog = true);
64 64
  	
65
-    /**
66
-     * Insert multiple records to the storage.
67
-     * 
68
-     * @param  array   $data
69
-     * @return object
70
-     */
71
-    public function saveMany(array $data);
65
+	/**
66
+	 * Insert multiple records to the storage.
67
+	 * 
68
+	 * @param  array   $data
69
+	 * @return object
70
+	 */
71
+	public function saveMany(array $data);
72 72
 
73 73
 	/**
74
-     * Update record in the storage based on the given
75
-     * condition.
76
-     * 
77
-     * @param  [type] $value condition value
78
-     * @param  array $data
79
-     * @param  string $attribute condition column name
80
-     * @return integer affected rows
81
-     */
82
-    public function update($value, array $data, $attribute = 'id');
74
+	 * Update record in the storage based on the given
75
+	 * condition.
76
+	 * 
77
+	 * @param  [type] $value condition value
78
+	 * @param  array $data
79
+	 * @param  string $attribute condition column name
80
+	 * @return integer affected rows
81
+	 */
82
+	public function update($value, array $data, $attribute = 'id');
83 83
  	
84 84
 	/**
85
-     * Delete record from the storage based on the given
86
-     * condition.
87
-     * 
88
-     * @param  [type] $value condition value
89
-     * @param  string $attribute condition column name
90
-     * @return integer affected rows
91
-     */
92
-    public function delete($value, $attribute = 'id');
85
+	 * Delete record from the storage based on the given
86
+	 * condition.
87
+	 * 
88
+	 * @param  [type] $value condition value
89
+	 * @param  string $attribute condition column name
90
+	 * @return integer affected rows
91
+	 */
92
+	public function delete($value, $attribute = 'id');
93 93
  	
94 94
 	/**
95
-     * Fetch records from the storage based on the given
96
-     * id.
97
-     * 
98
-     * @param  integer $id
99
-     * @param  array   $relations
100
-     * @param  array   $columns
101
-     * @return object
102
-     */
103
-    public function find($id, $relations = [], $columns = array('*'));
95
+	 * Fetch records from the storage based on the given
96
+	 * id.
97
+	 * 
98
+	 * @param  integer $id
99
+	 * @param  array   $relations
100
+	 * @param  array   $columns
101
+	 * @return object
102
+	 */
103
+	public function find($id, $relations = [], $columns = array('*'));
104 104
  	
105 105
 	/**
106
-     * Fetch records from the storage based on the given
107
-     * condition.
108
-     * 
109
-     * @param  array   $conditions array of conditions
110
-     * @param  array   $relations
111
-     * @param  array   $sortBy
112
-     * @param  array   $desc
113
-     * @param  array   $columns
114
-     * @return collection
115
-     */
116
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
106
+	 * Fetch records from the storage based on the given
107
+	 * condition.
108
+	 * 
109
+	 * @param  array   $conditions array of conditions
110
+	 * @param  array   $relations
111
+	 * @param  array   $sortBy
112
+	 * @param  array   $desc
113
+	 * @param  array   $columns
114
+	 * @return collection
115
+	 */
116
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
117 117
 
118
-    /**
119
-     * Fetch the first record fro the storage based on the given
120
-     * condition.
121
-     * 
122
-     * @param  array   $conditions array of conditions
123
-     * @param  [type]  $value condition value
124
-     * @param  array   $relations
125
-     * @param  array   $columns
126
-     * @return object
127
-     */
128
-    public function first($conditions, $relations = [], $columns = array('*'));
118
+	/**
119
+	 * Fetch the first record fro the storage based on the given
120
+	 * condition.
121
+	 * 
122
+	 * @param  array   $conditions array of conditions
123
+	 * @param  [type]  $value condition value
124
+	 * @param  array   $relations
125
+	 * @param  array   $columns
126
+	 * @return object
127
+	 */
128
+	public function first($conditions, $relations = [], $columns = array('*'));
129 129
 }
130 130
\ No newline at end of file
Please login to merge, or discard this patch.