Completed
Push — master ( 5049fe...5fd7f0 )
by Sherif
02:43
created
src/Modules/V1/Core/AbstractRepositories/AbstractRepository.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      *
33 33
      * @param  array   $relations
34 34
      * @param  string  $sortBy
35
-     * @param  boolean $desc
35
+     * @param  integer $desc
36 36
      * @param  array   $columns
37 37
      * @return collection
38 38
      */
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @param  integer $perPage
51 51
      * @param  array   $relations
52 52
      * @param  string  $sortBy
53
-     * @param  boolean $desc
53
+     * @param  integer $desc
54 54
      * @param  array   $columns
55 55
      * @return collection
56 56
      */
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      * @param  integer $perPage
98 98
      * @param  array   $relations
99 99
      * @param  string  $sortBy
100
-     * @param  boolean $desc
100
+     * @param  integer $desc
101 101
      * @param  array   $columns
102 102
      * @return collection
103 103
      */
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @param  integer $perPage
116 116
      * @param  array   $relations
117 117
      * @param  string  $sortBy
118
-     * @param  boolean $desc
118
+     * @param  integer $desc
119 119
      * @param  array   $columns
120 120
      * @return collection
121 121
      */
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
      * @param  array   $conditions array of conditions
373 373
      * @param  array   $relations
374 374
      * @param  string  $sortBy
375
-     * @param  boolean $desc
375
+     * @param  integer $desc
376 376
      * @param  array   $columns
377 377
      * @return collection
378 378
      */
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
      * Abstract method that is called in after
434 434
      * the save method finish.
435 435
      * 
436
-     * @param  object  $model
436
+     * @param  boolean  $model
437 437
      * @param  array   $relations
438
-     * @return void
438
+     * @return boolean
439 439
      */
440 440
     protected function afterSave($model, $relations)
441 441
     {
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -60,26 +60,26 @@  discard block
 block discarded – undo
60 60
         $conditionColumns = $this->model->getFillable();
61 61
         $sort             = $desc ? 'desc' : 'asc';
62 62
 
63
-        $model->where(function ($q) use ($query, $conditionColumns, $relations){
64
-            $q->where(\DB::raw('LOWER(CAST(' . array_shift($conditionColumns) . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
63
+        $model->where(function($q) use ($query, $conditionColumns, $relations){
64
+            $q->where(\DB::raw('LOWER(CAST('.array_shift($conditionColumns).' AS TEXT))'), 'LIKE', '%'.strtolower($query).'%');
65 65
             foreach ($conditionColumns as $column) 
66 66
             {
67
-                $q->orWhere(\DB::raw('LOWER(CAST(' . $column . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
67
+                $q->orWhere(\DB::raw('LOWER(CAST('.$column.' AS TEXT))'), 'LIKE', '%'.strtolower($query).'%');
68 68
             }
69 69
             foreach ($relations as $relation) 
70 70
             {
71 71
                 $relation = explode('.', $relation)[0];
72 72
                 if (\Core::$relation()) 
73 73
                 {
74
-                    $q->orWhereHas($relation, function ($subModel) use ($query, $relation){
74
+                    $q->orWhereHas($relation, function($subModel) use ($query, $relation){
75 75
 
76
-                        $subModel->where(function ($q) use ($query, $relation){
76
+                        $subModel->where(function($q) use ($query, $relation){
77 77
 
78 78
                             $subConditionColumns = \Core::$relation()->model->getFillable();
79
-                            $q->where(\DB::raw('LOWER(CAST(' . array_shift($subConditionColumns) . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
79
+                            $q->where(\DB::raw('LOWER(CAST('.array_shift($subConditionColumns).' AS TEXT))'), 'LIKE', '%'.strtolower($query).'%');
80 80
                             foreach ($subConditionColumns as $subConditionColumn)
81 81
                             {
82
-                                $q->orWhere(\DB::raw('LOWER(CAST(' . $subConditionColumn . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
82
+                                $q->orWhere(\DB::raw('LOWER(CAST('.$subConditionColumn.' AS TEXT))'), 'LIKE', '%'.strtolower($query).'%');
83 83
                             } 
84 84
                         });
85 85
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $relations  = [];
142 142
         $with       = [];
143 143
 
144
-        \DB::transaction(function () use (&$model, &$relations, &$with, $data, $saveLog, $modelClass) {
144
+        \DB::transaction(function() use (&$model, &$relations, &$with, $data, $saveLog, $modelClass) {
145 145
             /**
146 146
              * If the id is present in the data then select the model for updating,
147 147
              * else create new model.
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             $model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
151 151
             if ( ! $model) 
152 152
             {
153
-                \ErrorHandler::notFound(class_basename($modelClass) . ' with id : ' . $data['id']);
153
+                \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']);
154 154
             }
155 155
 
156 156
             /**
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
                                 $relationModel = array_key_exists('id', $val) ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
182 182
                                 if ( ! $relationModel) 
183 183
                                 {
184
-                                    \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']);
184
+                                    \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
185 185
                                 }
186 186
 
187 187
                                 foreach ($val as $attr => $val) 
188 188
                                 {
189
-                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' &&  array_search($attr, $relationModel->getFillable(), true) !== false)
189
+                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false)
190 190
                                     {
191 191
                                         $relationModel->$attr = $val;
192 192
                                     }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
                                     $relationModel = array_key_exists('id', $value) ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
201 201
                                     if ( ! $relationModel) 
202 202
                                     {
203
-                                        \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']);
203
+                                        \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
204 204
                                     }
205 205
 
206 206
                                     if (array_search($attr, $relationModel->getFillable(), true) !== false) 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     public function saveMany(array $data)
288 288
     {
289 289
         $result = [];
290
-        \DB::transaction(function () use (&$result, $data) {
290
+        \DB::transaction(function() use (&$result, $data) {
291 291
             foreach ($data as $key => $value) 
292 292
             {
293 293
                 $result[] = $this->save($value);
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             $model ? $model->update($data) : 0;
314 314
             $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $value, $model) : false;
315 315
         }
316
-    	call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){
316
+    	call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data, $saveLog){
317 317
             $model->update($data);
318 318
             $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
319 319
         });
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
     {
332 332
     	if ($attribute == 'id') 
333 333
     	{
334
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
334
+            \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) {
335 335
                 $model = $this->model->lockForUpdate()->find($value);
336 336
                 $model->delete();
337 337
                 $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false;
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
     	}
340 340
         else
341 341
         {
342
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
343
-                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){
342
+            \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) {
343
+                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) {
344 344
                     $model->delete();
345 345
                     $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
346 346
                 });
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     {
378 378
         $conditions = $this->constructConditions($conditions);
379 379
         $sort       = $desc ? 'desc' : 'asc';
380
-        return call_user_func_array("{$this->getModel()}::with",  array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
380
+        return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
381 381
     }
382 382
 
383 383
     /**
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
         {
409 409
             if ($key == 'and') 
410 410
             {
411
-                $conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']) . ' {op} ';
411
+                $conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']).' {op} ';
412 412
                 $conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
413 413
             }
414 414
             else if ($key == 'or')
415 415
             {
416
-                $conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']) . ' {op} ';
416
+                $conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']).' {op} ';
417 417
                 $conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
418 418
             }
419 419
             else
420 420
             {
421
-                $conditionString  .= $key . '=? {op} ';
421
+                $conditionString  .= $key.'=? {op} ';
422 422
                 $conditionValues[] = $value;
423 423
             }
424 424
         }
425
-        $conditionString = '(' . rtrim($conditionString, '{op} ') . ')';
425
+        $conditionString = '('.rtrim($conditionString, '{op} ').')';
426 426
         return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
427 427
     }
428 428
 
Please login to merge, or discard this patch.
src/Modules/V1/Core/Http/Controllers/BaseApiController.php 2 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.
src/Modules/V1/Core/Interfaces/RepositoryInterface.php 1 patch
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.
src/Modules/V1/Reporting/Repositories/ReportRepository.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
      *
47 47
      * @param  array   $conditions array of conditions
48 48
      * @param  array   $relations
49
-     * @param  array   $colunmns
49
+     * @param  array   $columns
50 50
      * @return object
51 51
      */
52 52
     public function first($conditions, $relations = [], $columns = array('*'))
Please login to merge, or discard this patch.
src/Modules/V1/Core/Utl/CoreConfig.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
     public function getConfig()
6 6
     {
7 7
     	$customSettings = [];
8
-    	Settings::get(['key', 'value'])->each(function ($setting) use (&$customSettings){
8
+    	Settings::get(['key', 'value'])->each(function($setting) use (&$customSettings){
9 9
     		$customSettings[$setting['key']] = $setting['value'];
10 10
     	});
11 11
 
Please login to merge, or discard this patch.
src/Modules/V1/Core/Log.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 use Illuminate\Database\Eloquent\Model;
4 4
 use Illuminate\Database\Eloquent\SoftDeletes;
5 5
 
6
-class Log extends Model{
6
+class Log extends Model {
7 7
 
8 8
     use SoftDeletes;
9 9
     protected $table    = 'logs';
Please login to merge, or discard this patch.
src/Modules/V1/Core/Database/Migrations/2016_01_24_123630_settings.php 1 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('settings', function (Blueprint $table) {
15
+		Schema::create('settings', function(Blueprint $table) {
16 16
             $table->increments('id');
17
-            $table->string('name',100);
18
-            $table->string('key',100)->unique();
19
-            $table->string('value',100);
17
+            $table->string('name', 100);
18
+            $table->string('key', 100)->unique();
19
+            $table->string('value', 100);
20 20
             $table->softDeletes();
21 21
             $table->timestamps();
22 22
         });
Please login to merge, or discard this patch.
src/Modules/V1/Core/Database/Migrations/2016_01_19_084705_logs.php 1 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('logs', function (Blueprint $table) {
15
+		Schema::create('logs', function(Blueprint $table) {
16 16
 			$table->increments('id');
17
-			$table->string('action',100);
18
-			$table->string('item_name',100);
19
-			$table->string('item_type',100);
17
+			$table->string('action', 100);
18
+			$table->string('item_name', 100);
19
+			$table->string('item_type', 100);
20 20
 			$table->integer('item_id');
21 21
 			$table->integer('user_id');
22 22
 			$table->softDeletes();
Please login to merge, or discard this patch.
src/Modules/V1/Core/Settings.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@
 block discarded – undo
3 3
 use Illuminate\Database\Eloquent\Model;
4 4
 use Illuminate\Database\Eloquent\SoftDeletes;
5 5
 
6
-class Settings extends Model{
6
+class Settings extends Model {
7 7
 
8 8
     use SoftDeletes;
9 9
     protected $table    = 'settings';
10 10
     protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11 11
     protected $hidden   = ['deleted_at'];
12 12
     protected $guarded  = ['id', 'key'];
13
-    protected $fillable = ['name','value'];
13
+    protected $fillable = ['name', 'value'];
14 14
     
15 15
     public function getCreatedAtAttribute($value)
16 16
     {
Please login to merge, or discard this patch.