Completed
Push — master ( 7f4033...c0246b )
by Sherif
02:56
created
src/Modules/Acl/Http/Controllers/UsersController.php 5 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * Return the logged in user account.
43 43
      * 
44
-     * @return object
44
+     * @return \Illuminate\Http\JsonResponse
45 45
      */
46 46
     public function getAccount()
47 47
     {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     /**
53 53
      * Logout the user.
54 54
      * 
55
-     * @return void
55
+     * @return \Illuminate\Http\JsonResponse
56 56
      */
57 57
     public function getLogout()
58 58
     {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * Handle a registration request.
64 64
      *
65 65
      * @param  \Illuminate\Http\Request  $request
66
-     * @return \Illuminate\Http\Response
66
+     * @return \Illuminate\Http\JsonResponse
67 67
      */
68 68
     public function postRegister(Request $request)
69 69
     {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      * Handle a login request to the application.
77 77
      *
78 78
      * @param  \Illuminate\Http\Request  $request
79
-     * @return \Illuminate\Http\Response
79
+     * @return \Illuminate\Http\JsonResponse|null
80 80
      */
81 81
     public function postLogin(Request $request)
82 82
     {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * Handle an assign groups to user request.
97 97
      *
98 98
      * @param  \Illuminate\Http\Request  $request
99
-     * @return \Illuminate\Http\Response
99
+     * @return \Illuminate\Http\JsonResponse
100 100
      */
101 101
     public function postAssigngroups(Request $request)
102 102
     {
Please login to merge, or discard this patch.
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.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,8 +84,7 @@
 block discarded – undo
84 84
         {
85 85
             $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
86 86
             return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find(\Auth::id(), $relations), 200);
87
-        }
88
-        else
87
+        } else
89 88
         {
90 89
             $error = $this->errorHandler->loginFailed();
91 90
             abort($error['status'], $error['message']);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      * to preform actions like (add, edit ... etc).
13 13
      * @var string
14 14
      */
15
-    protected $model               = 'users';
15
+    protected $model = 'users';
16 16
 
17 17
     /**
18 18
      * List of all route actions that the base api controller
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * to check before add.
34 34
      * @var array
35 35
      */
36
-    protected $validationRules  = [
36
+    protected $validationRules = [
37 37
     'email'    => 'required|email|unique:users,email,{id}',
38 38
     'password' => 'min:6'
39 39
     ];
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/Core/Http/Controllers/BaseApiController.php 4 patches
Doc Comments   +13 added lines, -15 removed lines patch added patch discarded remove patch
@@ -54,9 +54,7 @@  discard block
 block discarded – undo
54 54
     /**
55 55
      * Fetch all records with relations from model repository.
56 56
      * 
57
-     * @param  string  $sortBy
58
-     * @param  boolean $desc
59
-     * @return \Illuminate\Http\Response
57
+     * @return \Illuminate\Http\JsonResponse|null
60 58
      */
61 59
     public function getIndex() 
62 60
     {
@@ -71,7 +69,7 @@  discard block
 block discarded – undo
71 69
      * Fetch the single object with relations from model repository.
72 70
      * 
73 71
      * @param  integer $id
74
-     * @return \Illuminate\Http\Response
72
+     * @return \Illuminate\Http\JsonResponse|null
75 73
      */
76 74
     public function getFind($id) 
77 75
     {
@@ -89,8 +87,8 @@  discard block
 block discarded – undo
89 87
      * @param  string  $query
90 88
      * @param  integer $perPage
91 89
      * @param  string  $sortBy
92
-     * @param  boolean $desc
93
-     * @return \Illuminate\Http\Response
90
+     * @param  integer $desc
91
+     * @return \Illuminate\Http\JsonResponse|null
94 92
      */
95 93
     public function getSearch($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
96 94
     {
@@ -107,8 +105,8 @@  discard block
 block discarded – undo
107 105
      * 
108 106
      * @param  \Illuminate\Http\Request  $request
109 107
      * @param  string  $sortBy
110
-     * @param  boolean $desc
111
-     * @return \Illuminate\Http\Response
108
+     * @param  integer $desc
109
+     * @return \Illuminate\Http\JsonResponse|null
112 110
      */
113 111
     public function postFindby(Request $request, $sortBy = 'created_at', $desc = 1) 
114 112
     {
@@ -124,7 +122,7 @@  discard block
 block discarded – undo
124 122
      * condition.
125 123
      * 
126 124
      * @param  \Illuminate\Http\Request  $request
127
-     * @return \Illuminate\Http\Response
125
+     * @return \Illuminate\Http\JsonResponse|null
128 126
      */
129 127
     public function postFirst(Request $request) 
130 128
     {
@@ -140,8 +138,8 @@  discard block
 block discarded – undo
140 138
      * 
141 139
      * @param  integer $perPage
142 140
      * @param  string  $sortBy
143
-     * @param  boolean $desc
144
-     * @return \Illuminate\Http\Response
141
+     * @param  integer $desc
142
+     * @return \Illuminate\Http\JsonResponse|null
145 143
      */
146 144
     public function getPaginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
147 145
     {
@@ -159,8 +157,8 @@  discard block
 block discarded – undo
159 157
      * @param  \Illuminate\Http\Request  $request
160 158
      * @param  integer $perPage
161 159
      * @param  string  $sortBy
162
-     * @param  boolean $desc
163
-     * @return \Illuminate\Http\Response
160
+     * @param  integer $desc
161
+     * @return \Illuminate\Http\JsonResponse|null
164 162
      */
165 163
     public function postPaginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
166 164
     {
@@ -175,7 +173,7 @@  discard block
 block discarded – undo
175 173
      * Save the given model to repository.
176 174
      * 
177 175
      * @param  \Illuminate\Http\Request  $request
178
-     * @return \Illuminate\Http\Response
176
+     * @return \Illuminate\Http\JsonResponse|null
179 177
      */
180 178
     public function postSave(Request $request) 
181 179
     {
@@ -208,7 +206,7 @@  discard block
 block discarded – undo
208 206
      * Delete by the given id from model repository.
209 207
      * 
210 208
      * @param  integer  $id
211
-     * @return \Illuminate\Http\Response
209
+     * @return \Illuminate\Http\JsonResponse|null
212 210
      */
213 211
     public function getDelete($id) 
214 212
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
         $this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
48 48
         
49 49
         $this->relations           = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
50
-        $route                     = explode('@',\Route::currentRouteAction())[1];
50
+        $route                     = explode('@', \Route::currentRouteAction())[1];
51 51
         $this->checkPermission(explode('_', snake_case($route))[1]);
52 52
     }
53 53
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -190,8 +190,7 @@  discard block
 block discarded – undo
190 190
             if ($request->has('id')) 
191 191
             {
192 192
                 $rule = str_replace('{id}', $request->get('id'), $rule);
193
-            }
194
-            else
193
+            } else
195 194
             {
196 195
                 $rule = str_replace(',{id}', '', $rule);
197 196
             }
@@ -232,8 +231,7 @@  discard block
 block discarded – undo
232 231
         {
233 232
             $error = $this->errorHandler->notFound('method');
234 233
             abort($error['status'], $error['message']);
235
-        }
236
-        else if ( ! in_array($permission, $this->skipLoginCheck)) 
234
+        } else if ( ! in_array($permission, $this->skipLoginCheck)) 
237 235
         {
238 236
             \JWTAuth::parseToken()->authenticate();
239 237
             if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
Please login to merge, or discard this patch.
Indentation   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -6,223 +6,223 @@
 block discarded – undo
6 6
 
7 7
 class BaseApiController extends Controller
8 8
 {
9
-    /**
10
-     * The model implementation.
11
-     * 
12
-     * @var model
13
-     */
14
-    protected $model;
15
-
16
-    /**
17
-     * The config implementation.
18
-     * 
19
-     * @var config
20
-     */
21
-    protected $config;
22
-
23
-    public function __construct()
24
-    {
25
-        \Session::set('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
9
+	/**
10
+	 * The model implementation.
11
+	 * 
12
+	 * @var model
13
+	 */
14
+	protected $model;
15
+
16
+	/**
17
+	 * The config implementation.
18
+	 * 
19
+	 * @var config
20
+	 */
21
+	protected $config;
22
+
23
+	public function __construct()
24
+	{
25
+		\Session::set('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
26 26
         
27
-        $this->config              = \CoreConfig::getConfig();
28
-        $this->model               = property_exists($this, 'model') ? $this->model : false;
29
-        $this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
30
-        $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
31
-        $this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
32
-        $this->relations           = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
33
-        $route                     = explode('@',\Route::currentRouteAction())[1];
34
-        $this->checkPermission(explode('_', snake_case($route))[1]);
35
-    }
36
-
37
-    /**
38
-     * Fetch all records with relations from model repository.
39
-     * 
40
-     * @param  string  $sortBy
41
-     * @param  boolean $desc
42
-     * @return \Illuminate\Http\Response
43
-     */
44
-    public function getIndex() 
45
-    {
46
-        if ($this->model)
47
-        {
48
-            $relations = $this->relations && $this->relations['all'] ? $this->relations['all'] : [];
49
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->all($relations), 200);
50
-        }
51
-    }
52
-
53
-    /**
54
-     * Fetch the single object with relations from model repository.
55
-     * 
56
-     * @param  integer $id
57
-     * @return \Illuminate\Http\Response
58
-     */
59
-    public function getFind($id) 
60
-    {
61
-        if ($this->model) 
62
-        {
63
-            $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
64
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find($id, $relations), 200);
65
-        }
66
-    }
67
-
68
-    /**
69
-     * Paginate all records with relations from model repository
70
-     * that matche the given query.
71
-     * 
72
-     * @param  string  $query
73
-     * @param  integer $perPage
74
-     * @param  string  $sortBy
75
-     * @param  boolean $desc
76
-     * @return \Illuminate\Http\Response
77
-     */
78
-    public function getSearch($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
79
-    {
80
-        if ($this->model) 
81
-        {
82
-            $relations = $this->relations && $this->relations['paginate'] ? $this->relations['paginate'] : [];
83
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->search($query, $perPage, $relations, $sortBy, $desc), 200);
84
-        }
85
-    }
86
-
87
-    /**
88
-     * Fetch records from the storage based on the given
89
-     * condition.
90
-     * 
91
-     * @param  \Illuminate\Http\Request  $request
92
-     * @param  string  $sortBy
93
-     * @param  boolean $desc
94
-     * @return \Illuminate\Http\Response
95
-     */
96
-    public function postFindby(Request $request, $sortBy = 'created_at', $desc = 1) 
97
-    {
98
-        if ($this->model) 
99
-        {
100
-            $relations = $this->relations && $this->relations['findBy'] ? $this->relations['findBy'] : [];
101
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->findBy($request->all(), $relations, $sortBy, $desc), 200);
102
-        }
103
-    }
104
-
105
-    /**
106
-     * Fetch the first record from the storage based on the given
107
-     * condition.
108
-     * 
109
-     * @param  \Illuminate\Http\Request  $request
110
-     * @return \Illuminate\Http\Response
111
-     */
112
-    public function postFirst(Request $request) 
113
-    {
114
-        if ($this->model) 
115
-        {
116
-            $relations = $this->relations && $this->relations['first'] ? $this->relations['first'] : [];
117
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->first($request->all(), $relations), 200);
118
-        }
119
-    }
120
-
121
-    /**
122
-     * Paginate all records with relations from model repository.
123
-     * 
124
-     * @param  integer $perPage
125
-     * @param  string  $sortBy
126
-     * @param  boolean $desc
127
-     * @return \Illuminate\Http\Response
128
-     */
129
-    public function getPaginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
130
-    {
131
-        if ($this->model) 
132
-        {
133
-            $relations = $this->relations && $this->relations['paginate'] ? $this->relations['paginate'] : [];
134
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginate($perPage, $relations, $sortBy, $desc), 200);
135
-        }
136
-    }
137
-
138
-    /**
139
-     * Fetch all records with relations based on
140
-     * the given condition from storage in pages.
141
-     * 
142
-     * @param  \Illuminate\Http\Request  $request
143
-     * @param  integer $perPage
144
-     * @param  string  $sortBy
145
-     * @param  boolean $desc
146
-     * @return \Illuminate\Http\Response
147
-     */
148
-    public function postPaginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
149
-    {
150
-        if ($this->model) 
151
-        {
152
-            $relations = $this->relations && $this->relations['paginateBy'] ? $this->relations['paginateBy'] : [];
153
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginateBy($request->all(), $perPage, $relations, $sortBy, $desc), 200);
154
-        }
155
-    }
156
-
157
-    /**
158
-     * Save the given model to repository.
159
-     * 
160
-     * @param  \Illuminate\Http\Request  $request
161
-     * @return \Illuminate\Http\Response
162
-     */
163
-    public function postSave(Request $request) 
164
-    {
165
-        foreach ($this->validationRules as &$rule) 
166
-        {
167
-            if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
168
-            {
169
-                $rule .= ',deleted_at,NULL';
170
-            }
171
-
172
-            if ($request->has('id')) 
173
-            {
174
-                $rule = str_replace('{id}', $request->get('id'), $rule);
175
-            }
176
-            else
177
-            {
178
-                $rule = str_replace(',{id}', '', $rule);
179
-            }
180
-        }
27
+		$this->config              = \CoreConfig::getConfig();
28
+		$this->model               = property_exists($this, 'model') ? $this->model : false;
29
+		$this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
30
+		$this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
31
+		$this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
32
+		$this->relations           = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
33
+		$route                     = explode('@',\Route::currentRouteAction())[1];
34
+		$this->checkPermission(explode('_', snake_case($route))[1]);
35
+	}
36
+
37
+	/**
38
+	 * Fetch all records with relations from model repository.
39
+	 * 
40
+	 * @param  string  $sortBy
41
+	 * @param  boolean $desc
42
+	 * @return \Illuminate\Http\Response
43
+	 */
44
+	public function getIndex() 
45
+	{
46
+		if ($this->model)
47
+		{
48
+			$relations = $this->relations && $this->relations['all'] ? $this->relations['all'] : [];
49
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->all($relations), 200);
50
+		}
51
+	}
52
+
53
+	/**
54
+	 * Fetch the single object with relations from model repository.
55
+	 * 
56
+	 * @param  integer $id
57
+	 * @return \Illuminate\Http\Response
58
+	 */
59
+	public function getFind($id) 
60
+	{
61
+		if ($this->model) 
62
+		{
63
+			$relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
64
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find($id, $relations), 200);
65
+		}
66
+	}
67
+
68
+	/**
69
+	 * Paginate all records with relations from model repository
70
+	 * that matche the given query.
71
+	 * 
72
+	 * @param  string  $query
73
+	 * @param  integer $perPage
74
+	 * @param  string  $sortBy
75
+	 * @param  boolean $desc
76
+	 * @return \Illuminate\Http\Response
77
+	 */
78
+	public function getSearch($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
79
+	{
80
+		if ($this->model) 
81
+		{
82
+			$relations = $this->relations && $this->relations['paginate'] ? $this->relations['paginate'] : [];
83
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->search($query, $perPage, $relations, $sortBy, $desc), 200);
84
+		}
85
+	}
86
+
87
+	/**
88
+	 * Fetch records from the storage based on the given
89
+	 * condition.
90
+	 * 
91
+	 * @param  \Illuminate\Http\Request  $request
92
+	 * @param  string  $sortBy
93
+	 * @param  boolean $desc
94
+	 * @return \Illuminate\Http\Response
95
+	 */
96
+	public function postFindby(Request $request, $sortBy = 'created_at', $desc = 1) 
97
+	{
98
+		if ($this->model) 
99
+		{
100
+			$relations = $this->relations && $this->relations['findBy'] ? $this->relations['findBy'] : [];
101
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->findBy($request->all(), $relations, $sortBy, $desc), 200);
102
+		}
103
+	}
104
+
105
+	/**
106
+	 * Fetch the first record from the storage based on the given
107
+	 * condition.
108
+	 * 
109
+	 * @param  \Illuminate\Http\Request  $request
110
+	 * @return \Illuminate\Http\Response
111
+	 */
112
+	public function postFirst(Request $request) 
113
+	{
114
+		if ($this->model) 
115
+		{
116
+			$relations = $this->relations && $this->relations['first'] ? $this->relations['first'] : [];
117
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->first($request->all(), $relations), 200);
118
+		}
119
+	}
120
+
121
+	/**
122
+	 * Paginate all records with relations from model repository.
123
+	 * 
124
+	 * @param  integer $perPage
125
+	 * @param  string  $sortBy
126
+	 * @param  boolean $desc
127
+	 * @return \Illuminate\Http\Response
128
+	 */
129
+	public function getPaginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
130
+	{
131
+		if ($this->model) 
132
+		{
133
+			$relations = $this->relations && $this->relations['paginate'] ? $this->relations['paginate'] : [];
134
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginate($perPage, $relations, $sortBy, $desc), 200);
135
+		}
136
+	}
137
+
138
+	/**
139
+	 * Fetch all records with relations based on
140
+	 * the given condition from storage in pages.
141
+	 * 
142
+	 * @param  \Illuminate\Http\Request  $request
143
+	 * @param  integer $perPage
144
+	 * @param  string  $sortBy
145
+	 * @param  boolean $desc
146
+	 * @return \Illuminate\Http\Response
147
+	 */
148
+	public function postPaginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
149
+	{
150
+		if ($this->model) 
151
+		{
152
+			$relations = $this->relations && $this->relations['paginateBy'] ? $this->relations['paginateBy'] : [];
153
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginateBy($request->all(), $perPage, $relations, $sortBy, $desc), 200);
154
+		}
155
+	}
156
+
157
+	/**
158
+	 * Save the given model to repository.
159
+	 * 
160
+	 * @param  \Illuminate\Http\Request  $request
161
+	 * @return \Illuminate\Http\Response
162
+	 */
163
+	public function postSave(Request $request) 
164
+	{
165
+		foreach ($this->validationRules as &$rule) 
166
+		{
167
+			if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
168
+			{
169
+				$rule .= ',deleted_at,NULL';
170
+			}
171
+
172
+			if ($request->has('id')) 
173
+			{
174
+				$rule = str_replace('{id}', $request->get('id'), $rule);
175
+			}
176
+			else
177
+			{
178
+				$rule = str_replace(',{id}', '', $rule);
179
+			}
180
+		}
181 181
         
182
-        $this->validate($request, $this->validationRules);
183
-
184
-        if ($this->model) 
185
-        {
186
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->save($request->all()), 200);
187
-        }
188
-    }
189
-
190
-    /**
191
-     * Delete by the given id from model repository.
192
-     * 
193
-     * @param  integer  $id
194
-     * @return \Illuminate\Http\Response
195
-     */
196
-    public function getDelete($id) 
197
-    {
198
-        if ($this->model) 
199
-        {
200
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->delete($id), 200);
201
-        }
202
-    }
203
-
204
-    /**
205
-     * Check if the logged in user can do the given permission.
206
-     * 
207
-     * @param  string $permission
208
-     * @return void
209
-     */
210
-    private function checkPermission($permission)
211
-    {
212
-        $permission = $permission !== 'index' ? $permission : 'list';
213
-        if ($permission == 'method') 
214
-        {
215
-            $error = \ErrorHandler::notFound('method');
216
-            abort($error['status'], $error['message']);
217
-        }
218
-        else if ( ! in_array($permission, $this->skipLoginCheck)) 
219
-        {
220
-            \JWTAuth::parseToken()->authenticate();
221
-            if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
222
-            {
223
-                $error = \ErrorHandler::noPermissions();
224
-                abort($error['status'], $error['message']);
225
-            }
226
-        }
227
-    }
182
+		$this->validate($request, $this->validationRules);
183
+
184
+		if ($this->model) 
185
+		{
186
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->save($request->all()), 200);
187
+		}
188
+	}
189
+
190
+	/**
191
+	 * Delete by the given id from model repository.
192
+	 * 
193
+	 * @param  integer  $id
194
+	 * @return \Illuminate\Http\Response
195
+	 */
196
+	public function getDelete($id) 
197
+	{
198
+		if ($this->model) 
199
+		{
200
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->delete($id), 200);
201
+		}
202
+	}
203
+
204
+	/**
205
+	 * Check if the logged in user can do the given permission.
206
+	 * 
207
+	 * @param  string $permission
208
+	 * @return void
209
+	 */
210
+	private function checkPermission($permission)
211
+	{
212
+		$permission = $permission !== 'index' ? $permission : 'list';
213
+		if ($permission == 'method') 
214
+		{
215
+			$error = \ErrorHandler::notFound('method');
216
+			abort($error['status'], $error['message']);
217
+		}
218
+		else if ( ! in_array($permission, $this->skipLoginCheck)) 
219
+		{
220
+			\JWTAuth::parseToken()->authenticate();
221
+			if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
222
+			{
223
+				$error = \ErrorHandler::noPermissions();
224
+				abort($error['status'], $error['message']);
225
+			}
226
+		}
227
+	}
228 228
 }
Please login to merge, or discard this patch.
src/Modules/Core/Interfaces/RepositoryInterface.php 2 patches
Doc Comments   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
      * 
8 8
      * @param  array  $relations
9 9
      * @param  array   $sortBy
10
-     * @param  array   $desc
10
+     * @param  integer   $desc
11 11
      * @param  array  $columns
12 12
      * @return collection
13 13
      */
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * @param  integer $perPage
22 22
      * @param  array   $relations
23 23
      * @param  array   $sortBy
24
-     * @param  array   $desc
24
+     * @param  integer   $desc
25 25
      * @param  array   $columns
26 26
      * @return collection
27 27
      */
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * @param  integer $perPage
34 34
      * @param  array   $relations
35 35
      * @param  array   $sortBy
36
-     * @param  array   $desc
36
+     * @param  integer   $desc
37 37
      * @param  array   $columns
38 38
      * @return collection
39 39
      */
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param  integer $perPage
48 48
      * @param  array   $relations
49 49
      * @param  array   $sortBy
50
-     * @param  array   $desc
50
+     * @param  integer   $desc
51 51
      * @param  array   $columns
52 52
      * @return collection
53 53
      */
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @param  array   $conditions array of conditions
110 110
      * @param  array   $relations
111 111
      * @param  array   $sortBy
112
-     * @param  array   $desc
112
+     * @param  integer   $desc
113 113
      * @param  array   $columns
114 114
      * @return collection
115 115
      */
@@ -120,7 +120,6 @@  discard block
 block discarded – undo
120 120
      * condition.
121 121
      * 
122 122
      * @param  array   $conditions array of conditions
123
-     * @param  [type]  $value condition value
124 123
      * @param  array   $relations
125 124
      * @param  array   $columns
126 125
      * @return object
Please login to merge, or discard this 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 array
70
-     */
71
-    public function saveMany(array $data);
65
+	/**
66
+	 * Insert multiple records to the storage.
67
+	 * 
68
+	 * @param  array   $data
69
+	 * @return array
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.
src/Modules/Acl/AclGroup.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use Illuminate\Database\Eloquent\Model;
4 4
 use Illuminate\Database\Eloquent\SoftDeletes;
5 5
 
6
-class AclGroup extends Model{
6
+class AclGroup extends Model {
7 7
 
8 8
     use SoftDeletes;
9 9
     protected $table    = 'groups';
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function users()
31 31
     {
32
-        return $this->belongsToMany('\App\Modules\Acl\AclUser','users_groups','group_id','user_id')->whereNull('users_groups.deleted_at')->withTimestamps();
32
+        return $this->belongsToMany('\App\Modules\Acl\AclUser', 'users_groups', 'group_id', 'user_id')->whereNull('users_groups.deleted_at')->withTimestamps();
33 33
     }
34 34
 
35 35
     public function permissions()
36 36
     {
37
-        return $this->belongsToMany('\App\Modules\Acl\AclPermission','groups_permissions','group_id','permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
37
+        return $this->belongsToMany('\App\Modules\Acl\AclPermission', 'groups_permissions', 'group_id', 'permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
38 38
     }
39 39
 
40 40
     public static function boot()
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -5,41 +5,41 @@
 block discarded – undo
5 5
 
6 6
 class AclGroup extends Model{
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'groups';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at'];
12
-    protected $guarded  = ['id'];
13
-    protected $fillable = ['name'];
14
-
15
-    public function getCreatedAtAttribute($value)
16
-    {
17
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
-    }
19
-
20
-    public function getUpdatedAtAttribute($value)
21
-    {
22
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
-    }
24
-
25
-    public function getDeletedAtAttribute($value)
26
-    {
27
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
-    }
29
-
30
-    public function users()
31
-    {
32
-        return $this->belongsToMany('\App\Modules\Acl\AclUser','users_groups','group_id','user_id')->whereNull('users_groups.deleted_at')->withTimestamps();
33
-    }
34
-
35
-    public function permissions()
36
-    {
37
-        return $this->belongsToMany('\App\Modules\Acl\AclPermission','groups_permissions','group_id','permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
38
-    }
39
-
40
-    public static function boot()
41
-    {
42
-        parent::boot();
43
-        parent::observe(\App::make('App\Modules\Acl\ModelObservers\AclGroupObserver'));
44
-    }
8
+	use SoftDeletes;
9
+	protected $table    = 'groups';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at'];
12
+	protected $guarded  = ['id'];
13
+	protected $fillable = ['name'];
14
+
15
+	public function getCreatedAtAttribute($value)
16
+	{
17
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
+	}
19
+
20
+	public function getUpdatedAtAttribute($value)
21
+	{
22
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
+	}
24
+
25
+	public function getDeletedAtAttribute($value)
26
+	{
27
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
+	}
29
+
30
+	public function users()
31
+	{
32
+		return $this->belongsToMany('\App\Modules\Acl\AclUser','users_groups','group_id','user_id')->whereNull('users_groups.deleted_at')->withTimestamps();
33
+	}
34
+
35
+	public function permissions()
36
+	{
37
+		return $this->belongsToMany('\App\Modules\Acl\AclPermission','groups_permissions','group_id','permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
38
+	}
39
+
40
+	public static function boot()
41
+	{
42
+		parent::boot();
43
+		parent::observe(\App::make('App\Modules\Acl\ModelObservers\AclGroupObserver'));
44
+	}
45 45
 }
Please login to merge, or discard this patch.
src/Modules/Acl/Repositories/UserRepository.php 2 patches
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.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	 * @param  boolean $user
24 24
 	 * @return boolean
25 25
 	 */
26
-	public function can($nameOfPermission, $model, $user = false )
26
+	public function can($nameOfPermission, $model, $user = false)
27 27
 	{		
28 28
 		$user        = $user ?: \Auth::user();
29 29
 		$permissions = [];
30
-		\Core::users()->find($user->id, ['groups.permissions'])->groups->lists('permissions')->each(function ($permission) use (&$permissions, $model){
30
+		\Core::users()->find($user->id, ['groups.permissions'])->groups->lists('permissions')->each(function($permission) use (&$permissions, $model){
31 31
 			$permissions = array_merge($permissions, $permission->where('model', $model)->lists('name')->toArray()); 
32 32
 		});
33 33
 		
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function assignGroups($user_id, $group_ids)
57 57
 	{
58
-		\DB::transaction(function () use ($user_id, $group_ids) {
58
+		\DB::transaction(function() use ($user_id, $group_ids) {
59 59
 			$user = \Core::users()->find($user_id);
60 60
 			$user->groups()->detach();
61 61
 			$user->groups()->attach($group_ids);
Please login to merge, or discard this patch.
src/Modules/Acl/Repositories/GroupRepository.php 2 patches
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 	 */
24 24
 	public function assignPermissions($group_id, $permission_ids)
25 25
 	{
26
-		\DB::transaction(function () use ($group_id, $permission_ids) {
26
+		\DB::transaction(function() use ($group_id, $permission_ids) {
27 27
 			$group = \Core::groups()->find($group_id);
28 28
 			$group->permissions()->detach();
29 29
 			$group->permissions()->attach($permission_ids);
Please login to merge, or discard this patch.
src/Modules/Acl/Http/Controllers/GroupsController.php 2 patches
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.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
      * to preform actions like (add, edit ... etc).
14 14
      * @var string
15 15
      */
16
-    protected $model               = 'groups';
16
+    protected $model = 'groups';
17 17
 
18 18
     /**
19 19
      * The validations rules used by the base api controller
20 20
      * to check before add.
21 21
      * @var array
22 22
      */
23
-    protected $validationRules  = [
23
+    protected $validationRules = [
24 24
     'name' => 'required|string|max:100|unique:groups,name,{id}'
25 25
     ];
26 26
 
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 2 patches
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.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-		Schema::create('users', function (Blueprint $table) {
15
+		Schema::create('users', function(Blueprint $table) {
16 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();
17
+            $table->string('first_name', 100)->nullable();
18
+            $table->string('last_name', 100)->nullable();
19
+            $table->string('user_name', 100)->nullable();
20 20
             $table->text('address')->nullable();
21 21
             $table->string('email')->unique();
22 22
             $table->string('password', 60);
Please login to merge, or discard this patch.