Completed
Push — master ( 11bc64...21ebc1 )
by Sherif
11:54
created
src/Modules/V1/Core/AbstractRepositories/AbstractRepositoryContainer.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,39 +4,39 @@
 block discarded – undo
4 4
 
5 5
 abstract class AbstractRepositoryContainer implements RepositoryContainerInterface
6 6
 {
7
-    /**
8
-     * Construct the repository class name based on
9
-     * the method name called, search in the 
10
-     * given namespaces for the class and 
11
-     * return an instance.
12
-     * 
13
-     * @param  string $name the called method name
14
-     * @param  array  $arguments the method arguments
15
-     * @return object
16
-     */
17
-    public function __call($name, $arguments)
18
-    {
19
-        foreach ($this->getRepoNameSpace() as $repoNameSpace) 
20
-        {
21
-            $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository';
22
-            if (class_exists($class)) 
23
-            {
24
-                \App::singleton($class, function ($app) use ($class) {
7
+	/**
8
+	 * Construct the repository class name based on
9
+	 * the method name called, search in the 
10
+	 * given namespaces for the class and 
11
+	 * return an instance.
12
+	 * 
13
+	 * @param  string $name the called method name
14
+	 * @param  array  $arguments the method arguments
15
+	 * @return object
16
+	 */
17
+	public function __call($name, $arguments)
18
+	{
19
+		foreach ($this->getRepoNameSpace() as $repoNameSpace) 
20
+		{
21
+			$class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository';
22
+			if (class_exists($class)) 
23
+			{
24
+				\App::singleton($class, function ($app) use ($class) {
25 25
 
26
-                    return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']);
27
-                });
26
+					return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']);
27
+				});
28 28
 
29
-                return \App::make($class);
30
-            }
31
-        }
32
-    }
29
+				return \App::make($class);
30
+			}
31
+		}
32
+	}
33 33
 
34
-     /**
35
-     * Abstract methods that return the necessary 
36
-     * information (repositories namespaces)
37
-     * needed to preform the previous actions.
38
-     * 
39
-     * @return array
40
-     */
41
-    abstract protected function getRepoNameSpace();
34
+	 /**
35
+	  * Abstract methods that return the necessary 
36
+	  * information (repositories namespaces)
37
+	  * needed to preform the previous actions.
38
+	  * 
39
+	  * @return array
40
+	  */
41
+	abstract protected function getRepoNameSpace();
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Core/Decorators/CachingDecorator.php 1 patch
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -4,251 +4,251 @@
 block discarded – undo
4 4
 
5 5
 class CachingDecorator implements RepositoryInterface
6 6
 {
7
-    /**
8
-     * The repo implementation.
9
-     * 
10
-     * @var repo
11
-     */
12
-    protected $repo;
7
+	/**
8
+	 * The repo implementation.
9
+	 * 
10
+	 * @var repo
11
+	 */
12
+	protected $repo;
13 13
 
14
-    /**
15
-     * The cache implementation.
16
-     * 
17
-     * @var cache
18
-     */
19
-    protected $cache;
14
+	/**
15
+	 * The cache implementation.
16
+	 * 
17
+	 * @var cache
18
+	 */
19
+	protected $cache;
20 20
 
21
-    /**
22
-     * The model implementation.
23
-     * 
24
-     * @var model
25
-     */
26
-    public $model;
21
+	/**
22
+	 * The model implementation.
23
+	 * 
24
+	 * @var model
25
+	 */
26
+	public $model;
27 27
     
28
-    /**
29
-     * Create new CachingDecorator instance.
30
-     */
31
-    public function __construct($repo, $cache)
32
-    {   
33
-        $this->repo  = $repo;
34
-        $this->cache = $cache;
35
-        $this->model = get_class($this->repo->model);
36
-    }
28
+	/**
29
+	 * Create new CachingDecorator instance.
30
+	 */
31
+	public function __construct($repo, $cache)
32
+	{   
33
+		$this->repo  = $repo;
34
+		$this->cache = $cache;
35
+		$this->model = get_class($this->repo->model);
36
+	}
37 37
 
38
-    /**
39
-     * Fetch all records with relations from the storage.
40
-     *
41
-     * @param  array   $relations
42
-     * @param  string  $sortBy
43
-     * @param  boolean $desc
44
-     * @param  array   $columns
45
-     * @return collection
46
-     */
47
-    public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
48
-    {
49
-        $cacheKey = 'all';
50
-        return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($relations, $sortBy, $desc, $columns) {
51
-            return $this->repo->all($relations, $sortBy, $desc, $columns);
52
-        });
53
-    }
38
+	/**
39
+	 * Fetch all records with relations from the storage.
40
+	 *
41
+	 * @param  array   $relations
42
+	 * @param  string  $sortBy
43
+	 * @param  boolean $desc
44
+	 * @param  array   $columns
45
+	 * @return collection
46
+	 */
47
+	public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
48
+	{
49
+		$cacheKey = 'all';
50
+		return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($relations, $sortBy, $desc, $columns) {
51
+			return $this->repo->all($relations, $sortBy, $desc, $columns);
52
+		});
53
+	}
54 54
 
55
-    /**
56
-     * Fetch all records with relations from storage in pages 
57
-     * that matche the given query.
58
-     * 
59
-     * @param  string  $query
60
-     * @param  integer $perPage
61
-     * @param  array   $relations
62
-     * @param  string  $sortBy
63
-     * @param  boolean $desc
64
-     * @param  array   $columns
65
-     * @return collection
66
-     */
67
-    public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
68
-    {
69
-        $page     = \Request::get('page') ?? '1';
70
-        $cacheKey = 'search.' . $perPage . '.' . $query . '.' . $page;
71
-        return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($query, $perPage, $relations, $sortBy, $desc, $columns) {
72
-            return $this->repo->search($query, $perPage, $relations, $sortBy, $desc, $columns);
73
-        });
74
-    }
55
+	/**
56
+	 * Fetch all records with relations from storage in pages 
57
+	 * that matche the given query.
58
+	 * 
59
+	 * @param  string  $query
60
+	 * @param  integer $perPage
61
+	 * @param  array   $relations
62
+	 * @param  string  $sortBy
63
+	 * @param  boolean $desc
64
+	 * @param  array   $columns
65
+	 * @return collection
66
+	 */
67
+	public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
68
+	{
69
+		$page     = \Request::get('page') ?? '1';
70
+		$cacheKey = 'search.' . $perPage . '.' . $query . '.' . $page;
71
+		return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($query, $perPage, $relations, $sortBy, $desc, $columns) {
72
+			return $this->repo->search($query, $perPage, $relations, $sortBy, $desc, $columns);
73
+		});
74
+	}
75 75
     
76
-    /**
77
-     * Fetch all records with relations from storage in pages.
78
-     * 
79
-     * @param  integer $perPage
80
-     * @param  array   $relations
81
-     * @param  string  $sortBy
82
-     * @param  boolean $desc
83
-     * @param  array   $columns
84
-     * @return collection
85
-     */
86
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
87
-    {
88
-        $page     = \Request::get('page') ?? '1';
89
-        $cacheKey = 'paginate.' . $perPage . '.' . $page;
90
-        return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($perPage, $relations, $sortBy, $desc, $columns) {
91
-            return $this->repo->paginate($perPage, $relations, $sortBy, $desc, $columns);
92
-        });
93
-    }
76
+	/**
77
+	 * Fetch all records with relations from storage in pages.
78
+	 * 
79
+	 * @param  integer $perPage
80
+	 * @param  array   $relations
81
+	 * @param  string  $sortBy
82
+	 * @param  boolean $desc
83
+	 * @param  array   $columns
84
+	 * @return collection
85
+	 */
86
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
87
+	{
88
+		$page     = \Request::get('page') ?? '1';
89
+		$cacheKey = 'paginate.' . $perPage . '.' . $page;
90
+		return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($perPage, $relations, $sortBy, $desc, $columns) {
91
+			return $this->repo->paginate($perPage, $relations, $sortBy, $desc, $columns);
92
+		});
93
+	}
94 94
 
95
-    /**
96
-     * Fetch all records with relations based on
97
-     * the given condition from storage in pages.
98
-     * 
99
-     * @param  array   $conditions array of conditions
100
-     * @param  integer $perPage
101
-     * @param  array   $relations
102
-     * @param  string  $sortBy
103
-     * @param  boolean $desc
104
-     * @param  array   $columns
105
-     * @return collection
106
-     */
107
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
108
-    {
109
-        $page     = \Request::get('page') ?? '1';
110
-        $cacheKey = 'paginateBy.' . $perPage . '.' .  $page . '.' . serialize($conditions);
111
-        return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($conditions, $perPage, $relations, $sortBy, $desc, $columns) {
112
-            return $this->repo->paginateBy($conditions, $perPage, $relations, $sortBy, $desc, $columns);
113
-        });
114
-    }
95
+	/**
96
+	 * Fetch all records with relations based on
97
+	 * the given condition from storage in pages.
98
+	 * 
99
+	 * @param  array   $conditions array of conditions
100
+	 * @param  integer $perPage
101
+	 * @param  array   $relations
102
+	 * @param  string  $sortBy
103
+	 * @param  boolean $desc
104
+	 * @param  array   $columns
105
+	 * @return collection
106
+	 */
107
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
108
+	{
109
+		$page     = \Request::get('page') ?? '1';
110
+		$cacheKey = 'paginateBy.' . $perPage . '.' .  $page . '.' . serialize($conditions);
111
+		return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($conditions, $perPage, $relations, $sortBy, $desc, $columns) {
112
+			return $this->repo->paginateBy($conditions, $perPage, $relations, $sortBy, $desc, $columns);
113
+		});
114
+	}
115 115
     
116
-    /**
117
-     * Save the given model to the storage.
118
-     * 
119
-     * @param  array   $data
120
-     * @param  boolean $saveLog
121
-     * @return void
122
-     */
123
-    public function save(array $data, $saveLog = true)
124
-    {
125
-        $this->cache->tags([$this->model])->flush();
126
-        return $this->repo->save($data, $saveLog);
127
-    }
116
+	/**
117
+	 * Save the given model to the storage.
118
+	 * 
119
+	 * @param  array   $data
120
+	 * @param  boolean $saveLog
121
+	 * @return void
122
+	 */
123
+	public function save(array $data, $saveLog = true)
124
+	{
125
+		$this->cache->tags([$this->model])->flush();
126
+		return $this->repo->save($data, $saveLog);
127
+	}
128 128
     
129
-    /**
130
-     * Update record in the storage based on the given
131
-     * condition.
132
-     * 
133
-     * @param  var $value condition value
134
-     * @param  array $data
135
-     * @param  string $attribute condition column name
136
-     * @return void
137
-     */
138
-    public function update($value, array $data, $attribute = 'id', $saveLog = true)
139
-    {
140
-        $this->cache->tags([$this->model])->flush();
141
-        return $this->repo->update($value, $data, $attribute, $saveLog);
142
-    }
129
+	/**
130
+	 * Update record in the storage based on the given
131
+	 * condition.
132
+	 * 
133
+	 * @param  var $value condition value
134
+	 * @param  array $data
135
+	 * @param  string $attribute condition column name
136
+	 * @return void
137
+	 */
138
+	public function update($value, array $data, $attribute = 'id', $saveLog = true)
139
+	{
140
+		$this->cache->tags([$this->model])->flush();
141
+		return $this->repo->update($value, $data, $attribute, $saveLog);
142
+	}
143 143
 
144
-    /**
145
-     * Delete record from the storage based on the given
146
-     * condition.
147
-     * 
148
-     * @param  var $value condition value
149
-     * @param  string $attribute condition column name
150
-     * @return void
151
-     */
152
-    public function delete($value, $attribute = 'id', $saveLog = true)
153
-    {
154
-        $this->cache->tags([$this->model])->flush();
155
-        return $this->repo->delete($value, $attribute, $saveLog);
156
-    }
144
+	/**
145
+	 * Delete record from the storage based on the given
146
+	 * condition.
147
+	 * 
148
+	 * @param  var $value condition value
149
+	 * @param  string $attribute condition column name
150
+	 * @return void
151
+	 */
152
+	public function delete($value, $attribute = 'id', $saveLog = true)
153
+	{
154
+		$this->cache->tags([$this->model])->flush();
155
+		return $this->repo->delete($value, $attribute, $saveLog);
156
+	}
157 157
     
158
-    /**
159
-     * Fetch records from the storage based on the given
160
-     * id.
161
-     * 
162
-     * @param  integer $id
163
-     * @param  array   $relations
164
-     * @param  array   $columns
165
-     * @return object
166
-     */
167
-    public function find($id, $relations = [], $columns = array('*'))
168
-    {
169
-        $cacheKey = 'find.' . $id;
170
-        return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($id, $relations, $columns) {
171
-            return $this->repo->find($id, $relations, $columns);
172
-        });
173
-    }
158
+	/**
159
+	 * Fetch records from the storage based on the given
160
+	 * id.
161
+	 * 
162
+	 * @param  integer $id
163
+	 * @param  array   $relations
164
+	 * @param  array   $columns
165
+	 * @return object
166
+	 */
167
+	public function find($id, $relations = [], $columns = array('*'))
168
+	{
169
+		$cacheKey = 'find.' . $id;
170
+		return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($id, $relations, $columns) {
171
+			return $this->repo->find($id, $relations, $columns);
172
+		});
173
+	}
174 174
     
175
-    /**
176
-     * Fetch records from the storage based on the given
177
-     * condition.
178
-     * 
179
-     * @param  array   $conditions array of conditions
180
-     * @param  array   $relations
181
-     * @param  string  $sortBy
182
-     * @param  boolean $desc
183
-     * @param  array   $columns
184
-     * @return collection
185
-     */
186
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
187
-    {
188
-        $cacheKey = 'findBy.' . serialize($conditions);
189
-        return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($conditions, $relations, $sortBy, $desc, $columns) {
190
-            return $this->repo->findBy($conditions, $relations, $sortBy, $desc, $columns);
191
-        });
192
-    }
175
+	/**
176
+	 * Fetch records from the storage based on the given
177
+	 * condition.
178
+	 * 
179
+	 * @param  array   $conditions array of conditions
180
+	 * @param  array   $relations
181
+	 * @param  string  $sortBy
182
+	 * @param  boolean $desc
183
+	 * @param  array   $columns
184
+	 * @return collection
185
+	 */
186
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
187
+	{
188
+		$cacheKey = 'findBy.' . serialize($conditions);
189
+		return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($conditions, $relations, $sortBy, $desc, $columns) {
190
+			return $this->repo->findBy($conditions, $relations, $sortBy, $desc, $columns);
191
+		});
192
+	}
193 193
 
194
-    /**
195
-     * Fetch the first record from the storage based on the given
196
-     * condition.
197
-     *
198
-     * @param  array   $conditions array of conditions
199
-     * @param  array   $relations
200
-     * @param  array   $columns
201
-     * @return object
202
-     */
203
-    public function first($conditions, $relations = [], $columns = array('*'))
204
-    {
205
-        $cacheKey = 'first.' . serialize($conditions);
206
-        return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($conditions, $relations, $columns) {
207
-            return $this->repo->first($conditions, $relations, $columns);
208
-        });  
209
-    }
194
+	/**
195
+	 * Fetch the first record from the storage based on the given
196
+	 * condition.
197
+	 *
198
+	 * @param  array   $conditions array of conditions
199
+	 * @param  array   $relations
200
+	 * @param  array   $columns
201
+	 * @return object
202
+	 */
203
+	public function first($conditions, $relations = [], $columns = array('*'))
204
+	{
205
+		$cacheKey = 'first.' . serialize($conditions);
206
+		return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($conditions, $relations, $columns) {
207
+			return $this->repo->first($conditions, $relations, $columns);
208
+		});  
209
+	}
210 210
 
211
-    /**
212
-     * Return the deleted models in pages based on the given conditions.
213
-     * 
214
-     * @param  array   $conditions array of conditions
215
-     * @param  integer $perPage
216
-     * @param  string  $sortBy
217
-     * @param  boolean $desc
218
-     * @param  array   $columns
219
-     * @return collection
220
-     */
221
-    public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = array('*'))
222
-    {
223
-        $page     = \Request::get('page') ?? '1';
224
-        $cacheKey = 'deleted.' . $perPage . '.' .  $page . '.' . serialize($conditions);
225
-        return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($conditions, $perPage, $sortBy, $desc, $columns) {
226
-            return $this->repo->deleted($conditions, $perPage, $sortBy, $desc, $columns);
227
-        });
228
-    }
211
+	/**
212
+	 * Return the deleted models in pages based on the given conditions.
213
+	 * 
214
+	 * @param  array   $conditions array of conditions
215
+	 * @param  integer $perPage
216
+	 * @param  string  $sortBy
217
+	 * @param  boolean $desc
218
+	 * @param  array   $columns
219
+	 * @return collection
220
+	 */
221
+	public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = array('*'))
222
+	{
223
+		$page     = \Request::get('page') ?? '1';
224
+		$cacheKey = 'deleted.' . $perPage . '.' .  $page . '.' . serialize($conditions);
225
+		return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($conditions, $perPage, $sortBy, $desc, $columns) {
226
+			return $this->repo->deleted($conditions, $perPage, $sortBy, $desc, $columns);
227
+		});
228
+	}
229 229
 
230
-    /**
231
-     * Restore the deleted model.
232
-     * 
233
-     * @param  integer $id
234
-     * @return void
235
-     */
236
-    public function restore($id)
237
-    {
238
-        $this->cache->tags([$this->model])->flush();
239
-        return $this->repo->restore($id);
240
-    }
230
+	/**
231
+	 * Restore the deleted model.
232
+	 * 
233
+	 * @param  integer $id
234
+	 * @return void
235
+	 */
236
+	public function restore($id)
237
+	{
238
+		$this->cache->tags([$this->model])->flush();
239
+		return $this->repo->restore($id);
240
+	}
241 241
 
242
-    /**
243
-     * Handle calling methods that is not implemented in the 
244
-     * abstract repository.
245
-     * 
246
-     * @param  string $name the called method name
247
-     * @param  array  $arguments the method arguments
248
-     * @return object
249
-     */
250
-    public function __call($name, $arguments)
251
-    {
252
-        return call_user_func_array([$this->repo, $name], $arguments);
253
-    }
242
+	/**
243
+	 * Handle calling methods that is not implemented in the 
244
+	 * abstract repository.
245
+	 * 
246
+	 * @param  string $name the called method name
247
+	 * @param  array  $arguments the method arguments
248
+	 * @return object
249
+	 */
250
+	public function __call($name, $arguments)
251
+	{
252
+		return call_user_func_array([$this->repo, $name], $arguments);
253
+	}
254 254
 }
255 255
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/UsersController.php 1 patch
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -7,252 +7,252 @@
 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', 'sendreset', 'changePassword'];
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', 'sendreset', 'changePassword'];
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', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken'];
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', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken'];
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
-        'name'     => 'nullable|string|unique:users,name,{id},id,name,NOT_NULL', 
38
-        'email'    => 'required|email|unique:users,email,{id},id,email,NOT_NULL', 
39
-        'password' => 'nullable|min:6'
40
-    ];
31
+	/**
32
+	 * The validations rules used by the base api controller
33
+	 * to check before add.
34
+	 * @var array
35
+	 */
36
+	protected $validationRules     = [
37
+		'name'     => 'nullable|string|unique:users,name,{id},id,name,NOT_NULL', 
38
+		'email'    => 'required|email|unique:users,email,{id},id,email,NOT_NULL', 
39
+		'password' => 'nullable|min:6'
40
+	];
41 41
 
42
-    /**
43
-     * Return the logged in user account.
44
-     * 
45
-     * @return \Illuminate\Http\Response
46
-     */
47
-    public function account()
48
-    {
49
-        $relations = $this->relations && $this->relations['account'] ? $this->relations['account'] : [];
50
-        return \Response::json(\Core::users()->account($relations), 200);
51
-    }
42
+	/**
43
+	 * Return the logged in user account.
44
+	 * 
45
+	 * @return \Illuminate\Http\Response
46
+	 */
47
+	public function account()
48
+	{
49
+		$relations = $this->relations && $this->relations['account'] ? $this->relations['account'] : [];
50
+		return \Response::json(\Core::users()->account($relations), 200);
51
+	}
52 52
 
53
-    /**
54
-     * Block the user.
55
-     *
56
-     * @param  integer  $id
57
-     * @return \Illuminate\Http\Response
58
-     */
59
-    public function block($id)
60
-    {
61
-        return \Response::json(\Core::users()->block($id), 200);
62
-    }
53
+	/**
54
+	 * Block the user.
55
+	 *
56
+	 * @param  integer  $id
57
+	 * @return \Illuminate\Http\Response
58
+	 */
59
+	public function block($id)
60
+	{
61
+		return \Response::json(\Core::users()->block($id), 200);
62
+	}
63 63
 
64
-    /**
65
-     * Unblock the user.
66
-     *
67
-     * @param  integer  $id
68
-     * @return \Illuminate\Http\Response
69
-     */
70
-    public function unblock($id)
71
-    {
72
-        return \Response::json(\Core::users()->unblock($id), 200);
73
-    }
64
+	/**
65
+	 * Unblock the user.
66
+	 *
67
+	 * @param  integer  $id
68
+	 * @return \Illuminate\Http\Response
69
+	 */
70
+	public function unblock($id)
71
+	{
72
+		return \Response::json(\Core::users()->unblock($id), 200);
73
+	}
74 74
 
75
-    /**
76
-     * Logout the user.
77
-     * 
78
-     * @return \Illuminate\Http\Response
79
-     */
80
-    public function logout()
81
-    {
82
-        return \Response::json(\Core::users()->logout(), 200);
83
-    }
75
+	/**
76
+	 * Logout the user.
77
+	 * 
78
+	 * @return \Illuminate\Http\Response
79
+	 */
80
+	public function logout()
81
+	{
82
+		return \Response::json(\Core::users()->logout(), 200);
83
+	}
84 84
 
85
-    /**
86
-     * Handle a registration request.
87
-     *
88
-     * @param  \Illuminate\Http\Request  $request
89
-     * @return \Illuminate\Http\Response
90
-     */
91
-    public function register(Request $request)
92
-    {
93
-        $this->validate($request, [
94
-            'name'     => 'nullable|string|unique:users,name,{id},id,name,NOT_NULL', 
95
-            'email'    => 'required|email|unique:users,email,{id},id,email,NOT_NULL', 
96
-            'password' => 'required|min:6'
97
-            ]);
85
+	/**
86
+	 * Handle a registration request.
87
+	 *
88
+	 * @param  \Illuminate\Http\Request  $request
89
+	 * @return \Illuminate\Http\Response
90
+	 */
91
+	public function register(Request $request)
92
+	{
93
+		$this->validate($request, [
94
+			'name'     => 'nullable|string|unique:users,name,{id},id,name,NOT_NULL', 
95
+			'email'    => 'required|email|unique:users,email,{id},id,email,NOT_NULL', 
96
+			'password' => 'required|min:6'
97
+			]);
98 98
 
99
-        return \Response::json(\Core::users()->register($request->only('email', 'password')), 200);
100
-    }
99
+		return \Response::json(\Core::users()->register($request->only('email', 'password')), 200);
100
+	}
101 101
 
102
-    /**
103
-     * Handle a login request of the none admin to the application.
104
-     *
105
-     * @param  \Illuminate\Http\Request  $request
106
-     * @return \Illuminate\Http\Response
107
-     */
108
-    public function login(Request $request)
109
-    {
110
-        $this->validate($request, [
111
-            'email'    => 'required|email', 
112
-            'password' => 'required|min:6',
113
-            'admin'    => 'boolean'
114
-            ]);
102
+	/**
103
+	 * Handle a login request of the none admin to the application.
104
+	 *
105
+	 * @param  \Illuminate\Http\Request  $request
106
+	 * @return \Illuminate\Http\Response
107
+	 */
108
+	public function login(Request $request)
109
+	{
110
+		$this->validate($request, [
111
+			'email'    => 'required|email', 
112
+			'password' => 'required|min:6',
113
+			'admin'    => 'boolean'
114
+			]);
115 115
 
116
-        return \Response::json(\Core::users()->login($request->only('email', 'password'), $request->get('admin')), 200);
117
-    }
116
+		return \Response::json(\Core::users()->login($request->only('email', 'password'), $request->get('admin')), 200);
117
+	}
118 118
 
119
-    /**
120
-     * Handle a social login request of the none admin to the application.
121
-     *
122
-     * @param  \Illuminate\Http\Request  $request
123
-     * @return \Illuminate\Http\Response
124
-     */
125
-    public function loginSocial(Request $request)
126
-    {
127
-        $this->validate($request, [
128
-            'auth_code'    => 'required_without:access_token',
129
-            'access_token' => 'required_without:auth_code',
130
-            'type'         => 'required|in:facebook,google'
131
-            ]);
119
+	/**
120
+	 * Handle a social login request of the none admin to the application.
121
+	 *
122
+	 * @param  \Illuminate\Http\Request  $request
123
+	 * @return \Illuminate\Http\Response
124
+	 */
125
+	public function loginSocial(Request $request)
126
+	{
127
+		$this->validate($request, [
128
+			'auth_code'    => 'required_without:access_token',
129
+			'access_token' => 'required_without:auth_code',
130
+			'type'         => 'required|in:facebook,google'
131
+			]);
132 132
 
133
-        return \Response::json(\Core::users()->loginSocial($request->only('auth_code', 'access_token', 'type')), 200);
134
-    }
133
+		return \Response::json(\Core::users()->loginSocial($request->only('auth_code', 'access_token', 'type')), 200);
134
+	}
135 135
 
136
-    /**
137
-     * Handle an assign groups to user request.
138
-     *
139
-     * @param  \Illuminate\Http\Request  $request
140
-     * @return \Illuminate\Http\Response
141
-     */
142
-    public function assigngroups(Request $request)
143
-    {
144
-        $this->validate($request, [
145
-            'group_ids' => 'required|exists:groups,id', 
146
-            'user_id'   => 'required|exists:users,id'
147
-            ]);
136
+	/**
137
+	 * Handle an assign groups to user request.
138
+	 *
139
+	 * @param  \Illuminate\Http\Request  $request
140
+	 * @return \Illuminate\Http\Response
141
+	 */
142
+	public function assigngroups(Request $request)
143
+	{
144
+		$this->validate($request, [
145
+			'group_ids' => 'required|exists:groups,id', 
146
+			'user_id'   => 'required|exists:users,id'
147
+			]);
148 148
 
149
-        return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200);
150
-    }
149
+		return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200);
150
+	}
151 151
 
152
-    /**
153
-     * Send a reset link to the given user.
154
-     *
155
-     * @param  \Illuminate\Http\Request  $request
156
-     * @return \Illuminate\Http\Response
157
-     */
158
-    public function sendreset(Request $request)
159
-    {
160
-        $this->validate($request, ['email' => 'required|email', 'url' => 'required|url']);
152
+	/**
153
+	 * Send a reset link to the given user.
154
+	 *
155
+	 * @param  \Illuminate\Http\Request  $request
156
+	 * @return \Illuminate\Http\Response
157
+	 */
158
+	public function sendreset(Request $request)
159
+	{
160
+		$this->validate($request, ['email' => 'required|email', 'url' => 'required|url']);
161 161
 
162
-        return \Response::json(\Core::users()->sendReset($request->only('email'), $request->get('url')), 200);
163
-    }
162
+		return \Response::json(\Core::users()->sendReset($request->only('email'), $request->get('url')), 200);
163
+	}
164 164
 
165
-    /**
166
-     * Reset the given user's password.
167
-     *
168
-     * @param  \Illuminate\Http\Request  $request
169
-     * @return \Illuminate\Http\Response
170
-     */
171
-    public function resetpassword(Request $request)
172
-    {
173
-        $this->validate($request, [
174
-            'token'                 => 'required',
175
-            'email'                 => 'required|email',
176
-            'password'              => 'required|confirmed|min:6',
177
-            'password_confirmation' => 'required',
178
-        ]);
165
+	/**
166
+	 * Reset the given user's password.
167
+	 *
168
+	 * @param  \Illuminate\Http\Request  $request
169
+	 * @return \Illuminate\Http\Response
170
+	 */
171
+	public function resetpassword(Request $request)
172
+	{
173
+		$this->validate($request, [
174
+			'token'                 => 'required',
175
+			'email'                 => 'required|email',
176
+			'password'              => 'required|confirmed|min:6',
177
+			'password_confirmation' => 'required',
178
+		]);
179 179
 
180
-        return \Response::json(\Core::users()->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200);
181
-    }
180
+		return \Response::json(\Core::users()->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200);
181
+	}
182 182
 
183
-    /**
184
-     * Change the logged in user password.
185
-     *
186
-     * @param  \Illuminate\Http\Request  $request
187
-     * @return \Illuminate\Http\Response
188
-     */
189
-    public function changePassword(Request $request)
190
-    {
191
-        $this->validate($request, [
192
-            'old_password'          => 'required',
193
-            'password'              => 'required|confirmed|min:6',
194
-            'password_confirmation' => 'required',
195
-        ]);
183
+	/**
184
+	 * Change the logged in user password.
185
+	 *
186
+	 * @param  \Illuminate\Http\Request  $request
187
+	 * @return \Illuminate\Http\Response
188
+	 */
189
+	public function changePassword(Request $request)
190
+	{
191
+		$this->validate($request, [
192
+			'old_password'          => 'required',
193
+			'password'              => 'required|confirmed|min:6',
194
+			'password_confirmation' => 'required',
195
+		]);
196 196
 
197
-        return \Response::json(\Core::users()->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200);
198
-    }
197
+		return \Response::json(\Core::users()->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200);
198
+	}
199 199
 
200
-    /**
201
-     * Refresh the expired login token.
202
-     *
203
-     * @return \Illuminate\Http\Response
204
-     */
205
-    public function refreshtoken()
206
-    {
207
-        return \Response::json(\Core::users()->refreshtoken(), 200);
208
-    }
200
+	/**
201
+	 * Refresh the expired login token.
202
+	 *
203
+	 * @return \Illuminate\Http\Response
204
+	 */
205
+	public function refreshtoken()
206
+	{
207
+		return \Response::json(\Core::users()->refreshtoken(), 200);
208
+	}
209 209
 
210
-    /**
211
-     * Paginate all users with inthe given group.
212
-     * 
213
-     * @param  \Illuminate\Http\Request  $request
214
-     * @param  string $groupName
215
-     * @param  integer $perPage
216
-     * @param  string  $sortBy
217
-     * @param  boolean $desc
218
-     * @return \Illuminate\Http\Response
219
-     */
220
-    public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1)
221
-    {
222
-        $relations = $this->relations && $this->relations['group'] ? $this->relations['group'] : [];
223
-        return \Response::json(\Core::users()->group($request->all(), $groupName, $relations, $perPage, $sortBy, $desc), 200);
224
-    }
210
+	/**
211
+	 * Paginate all users with inthe given group.
212
+	 * 
213
+	 * @param  \Illuminate\Http\Request  $request
214
+	 * @param  string $groupName
215
+	 * @param  integer $perPage
216
+	 * @param  string  $sortBy
217
+	 * @param  boolean $desc
218
+	 * @return \Illuminate\Http\Response
219
+	 */
220
+	public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1)
221
+	{
222
+		$relations = $this->relations && $this->relations['group'] ? $this->relations['group'] : [];
223
+		return \Response::json(\Core::users()->group($request->all(), $groupName, $relations, $perPage, $sortBy, $desc), 200);
224
+	}
225 225
 
226
-    /**
227
-     * Save the given data to the logged in user.
228
-     *
229
-     * @param  \Illuminate\Http\Request  $request
230
-     * @return \Illuminate\Http\Response
231
-     */
232
-    public function saveProfile(Request $request) 
233
-    {
234
-        foreach ($this->validationRules as &$rule) 
235
-        {
236
-            if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
237
-            {
238
-                $rule .= ',deleted_at,NULL';
239
-            }
226
+	/**
227
+	 * Save the given data to the logged in user.
228
+	 *
229
+	 * @param  \Illuminate\Http\Request  $request
230
+	 * @return \Illuminate\Http\Response
231
+	 */
232
+	public function saveProfile(Request $request) 
233
+	{
234
+		foreach ($this->validationRules as &$rule) 
235
+		{
236
+			if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
237
+			{
238
+				$rule .= ',deleted_at,NULL';
239
+			}
240 240
 
241
-            if ($request->has('id')) 
242
-            {
243
-                $rule = str_replace('{id}', $request->get('id'), $rule);
244
-            }
245
-            else
246
-            {
247
-                $rule = str_replace(',{id}', '', $rule);
248
-            }
249
-        }
241
+			if ($request->has('id')) 
242
+			{
243
+				$rule = str_replace('{id}', $request->get('id'), $rule);
244
+			}
245
+			else
246
+			{
247
+				$rule = str_replace(',{id}', '', $rule);
248
+			}
249
+		}
250 250
 
251
-        $this->validate($request, $this->validationRules);
251
+		$this->validate($request, $this->validationRules);
252 252
 
253
-        if ($this->model)
254
-        {
255
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->saveProfile($request->all()), 200);
256
-        }
257
-    }
253
+		if ($this->model)
254
+		{
255
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->saveProfile($request->all()), 200);
256
+		}
257
+	}
258 258
 }
Please login to merge, or discard this patch.