Completed
Push — master ( 7e51b9...91e5b0 )
by Sherif
04:01 queued 01:33
created
src/Modules/Core/Decorators/CachingDecorator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
 		if ($this->cacheConfig && $this->cacheConfig == 'cache') 
81 81
 		{
82 82
 			$page     = \Request::get('page') !== null ? \Request::get('page') : '1';
83
-			$cacheKey = $name . $page . \Session::get('locale') . serialize($arguments);
83
+			$cacheKey = $name.$page.\Session::get('locale').serialize($arguments);
84 84
 			return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) {
85 85
 				return call_user_func_array([$this->repo, $name], $arguments);
86 86
 			});
Please login to merge, or discard this patch.
src/Modules/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
 	public $searchable  = ['name', 'value', 'key'];
15 15
     
16 16
 	public function getCreatedAtAttribute($value)
Please login to merge, or discard this patch.
src/Modules/Core/Providers/RouteServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		Route::group([
55 55
 			'middleware' => 'web',
56 56
 			'namespace'  => $this->namespace,
57
-		], function ($router) {
57
+		], function($router) {
58 58
 			require module_path('core', 'Routes/web.php');
59 59
 		});
60 60
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			'middleware' => 'api',
73 73
 			'namespace'  => $this->namespace,
74 74
 			'prefix'     => 'api',
75
-		], function ($router) {
75
+		], function($router) {
76 76
 			require module_path('core', 'Routes/api.php');
77 77
 		});
78 78
 	}
Please login to merge, or discard this patch.
src/Modules/Core/AbstractRepositories/AbstractRepository.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 		/**
64 64
 		 * Construct the select conditions for the model.
65 65
 		 */
66
-		$model->where(function ($q) use ($query, $conditionColumns, $relations){
66
+		$model->where(function($q) use ($query, $conditionColumns, $relations){
67 67
 
68 68
 			if (count($conditionColumns)) 
69 69
 			{
70
-				$column = 'LOWER(' . array_shift($conditionColumns) . ')';
70
+				$column = 'LOWER('.array_shift($conditionColumns).')';
71 71
 				if (str_contains($column, '->')) 
72 72
 				{
73 73
 					$column = $this->wrapJsonSelector($column);
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 				/**
77 77
 				 * Use the first element in the model columns to construct the first condition.
78 78
 				 */
79
-				$q->where(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%');
79
+				$q->where(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%');
80 80
 			}
81 81
 
82 82
 			/**
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 			 */
85 85
 			foreach ($conditionColumns as $column) 
86 86
 			{
87
-				$column = 'LOWER(' . $column . ')';
87
+				$column = 'LOWER('.$column.')';
88 88
 				if (str_contains($column, '->')) 
89 89
 				{
90 90
 					$column = $this->wrapJsonSelector($column);
91 91
 				}
92 92
 
93
-				$q->orWhere(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%');
93
+				$q->orWhere(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%');
94 94
 			}
95 95
 
96 96
 			/**
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 					/**
112 112
 					 * Construct the relation condition.
113 113
 					 */
114
-					$q->orWhereHas($relation, function ($subModel) use ($query, $relation){
114
+					$q->orWhereHas($relation, function($subModel) use ($query, $relation){
115 115
 
116
-						$subModel->where(function ($q) use ($query, $relation){
116
+						$subModel->where(function($q) use ($query, $relation){
117 117
 
118 118
 							/**
119 119
 							 * Get columns of the relation.
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 							if (count($subConditionColumns)) 
124 124
 							{
125 125
 
126
-								$column = 'LOWER(' . array_shift($subConditionColumns) . ')';
126
+								$column = 'LOWER('.array_shift($subConditionColumns).')';
127 127
 								if (str_contains($column, '->')) 
128 128
 								{
129 129
 									$column = $this->wrapJsonSelector($column);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 								/**
133 133
 								 * Use the first element in the relation model columns to construct the first condition.
134 134
 								 */
135
-								$q->where(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%');
135
+								$q->where(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%');
136 136
 							}
137 137
 
138 138
 							/**
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 							 */
141 141
 							foreach ($subConditionColumns as $subConditionColumn)
142 142
 							{
143
-								$column = 'LOWER(' . $subConditionColumn . ')';
143
+								$column = 'LOWER('.$subConditionColumn.')';
144 144
 								if (str_contains($column, '->')) 
145 145
 								{
146 146
 									$column = $this->wrapJsonSelector($column);
147 147
 								}
148 148
                                 
149
-								$q->orWhere(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%');
149
+								$q->orWhere(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%');
150 150
 							} 
151 151
 						});
152 152
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		$modelClass = $this->model;
208 208
 		$relations  = [];
209 209
 
210
-		\DB::transaction(function () use (&$model, &$relations, $data, $modelClass) {
210
+		\DB::transaction(function() use (&$model, &$relations, $data, $modelClass) {
211 211
 			/**
212 212
 			 * If the id is present in the data then select the model for updating,
213 213
 			 * else create new model.
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			$model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
217 217
 			if ( ! $model) 
218 218
 			{
219
-				\ErrorHandler::notFound(class_basename($modelClass) . ' with id : ' . $data['id']);
219
+				\ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']);
220 220
 			}
221 221
 
222 222
 			/**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 								 */
275 275
 								if ( ! $relationModel) 
276 276
 								{
277
-									\ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']);
277
+									\ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
278 278
 								}
279 279
 
280 280
 								/**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 									/**
286 286
 									 * Prevent the sub relations or attributes not in the fillable.
287 287
 									 */
288
-									if (gettype($val) !== 'object' && gettype($val) !== 'array' &&  array_search($attr, $relationModel->getFillable(), true) !== false)
288
+									if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false)
289 289
 									{
290 290
 										$relationModel->$attr = $val;
291 291
 									}
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 									 */
316 316
 									if ( ! $relationModel) 
317 317
 									{
318
-										\ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']);
318
+										\ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
319 319
 									}
320 320
 
321 321
 									foreach ($value as $relationAttribute => $relationValue) 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 		}
475 475
 		else
476 476
 		{
477
-			call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data){
477
+			call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data){
478 478
 				$model->update($data);
479 479
 			});
480 480
 		}
@@ -492,11 +492,11 @@  discard block
 block discarded – undo
492 492
 	{
493 493
 		if ($attribute == 'id') 
494 494
 		{
495
-			\DB::transaction(function () use ($value, $attribute, &$result) {
495
+			\DB::transaction(function() use ($value, $attribute, &$result) {
496 496
 				$model = $this->model->lockForUpdate()->find($value);
497 497
 				if ( ! $model) 
498 498
 				{
499
-					\ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $value);
499
+					\ErrorHandler::notFound(class_basename($this->model).' with id : '.$value);
500 500
 				}
501 501
                 
502 502
 				$model->delete();
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 		}
505 505
 		else
506 506
 		{
507
-			\DB::transaction(function () use ($value, $attribute, &$result) {
508
-				call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){
507
+			\DB::transaction(function() use ($value, $attribute, &$result) {
508
+				call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) {
509 509
 					$model->delete();
510 510
 				});
511 511
 			});   
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	{
542 542
 		$conditions = $this->constructConditions($conditions, $this->model);
543 543
 		$sort       = $desc ? 'desc' : 'asc';
544
-		return call_user_func_array("{$this->getModel()}::with",  array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
544
+		return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
545 545
 	}
546 546
 
547 547
 	/**
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 			$model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
582 582
 		}
583 583
 
584
-		return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);;
584
+		return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns); ;
585 585
 	}
586 586
 
587 587
 	/**
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 
597 597
 		if ( ! $model) 
598 598
 		{
599
-			\ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $id);
599
+			\ErrorHandler::notFound(class_basename($this->model).' with id : '.$id);
600 600
 		}
601 601
 
602 602
 		$model->restore();
@@ -621,13 +621,13 @@  discard block
 block discarded – undo
621 621
 			if ($key == 'and') 
622 622
 			{
623 623
 				$conditions       = $this->constructConditions($value, $model);
624
-				$conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} ';
624
+				$conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} ';
625 625
 				$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
626 626
 			}
627 627
 			else if ($key == 'or')
628 628
 			{
629 629
 				$conditions       = $this->constructConditions($value, $model);
630
-				$conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} ';
630
+				$conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} ';
631 631
 				$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
632 632
 			}
633 633
 			else
@@ -652,41 +652,41 @@  discard block
 block discarded – undo
652 652
                 
653 653
 				if (strtolower($operator) == 'between') 
654 654
 				{
655
-					$conditionString  .= $key . ' >= ? and ';
655
+					$conditionString  .= $key.' >= ? and ';
656 656
 					$conditionValues[] = $value1;
657 657
 
658
-					$conditionString  .= $key . ' <= ? {op} ';
658
+					$conditionString  .= $key.' <= ? {op} ';
659 659
 					$conditionValues[] = $value2;
660 660
 				}
661 661
 				elseif (strtolower($operator) == 'in') 
662 662
 				{
663 663
 					$conditionValues  = array_merge($conditionValues, $value);
664 664
 					$inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
665
-					$conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} ';
665
+					$conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} ';
666 666
 				}
667 667
 				elseif (strtolower($operator) == 'null') 
668 668
 				{
669
-					$conditionString .= $key . ' is null {op} ';
669
+					$conditionString .= $key.' is null {op} ';
670 670
 				}
671 671
 				elseif (strtolower($operator) == 'not null') 
672 672
 				{
673
-					$conditionString .= $key . ' is not null {op} ';
673
+					$conditionString .= $key.' is not null {op} ';
674 674
 				}
675 675
 				elseif (strtolower($operator) == 'has') 
676 676
 				{
677 677
 					$sql              = $model->withTrashed()->has($key)->toSql();
678 678
 					$conditions       = $this->constructConditions($value, $model->$key()->getRelated());
679
-					$conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} ';
679
+					$conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].') {op} ';
680 680
 					$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
681 681
 				}
682 682
 				else
683 683
 				{
684
-					$conditionString  .= $key . ' ' . $operator . ' ? {op} ';
684
+					$conditionString  .= $key.' '.$operator.' ? {op} ';
685 685
 					$conditionValues[] = $value;
686 686
 				}
687 687
 			}
688 688
 		}
689
-		$conditionString = '(' . rtrim($conditionString, '{op} ') . ')';
689
+		$conditionString = '('.rtrim($conditionString, '{op} ').')';
690 690
 		return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
691 691
 	}
692 692
 
@@ -702,11 +702,11 @@  discard block
 block discarded – undo
702 702
 		$value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
703 703
 		$path       = explode('->', $value);
704 704
 		$field      = array_shift($path);
705
-		$result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
705
+		$result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) {
706 706
 			return '"'.$part.'"';
707 707
 		})->implode('.'));
708 708
         
709
-		return $removeLast === false ? $result : $result . ')';
709
+		return $removeLast === false ? $result : $result.')';
710 710
 	}
711 711
 
712 712
 	/**
Please login to merge, or discard this patch.
src/Modules/Core/AbstractRepositories/AbstractRepositoryContainer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
 	{
19 19
 		foreach ($this->getRepoNameSpace() as $repoNameSpace) 
20 20
 		{
21
-			$class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository';
21
+			$class = rtrim($repoNameSpace, '\\').'\\'.ucfirst(str_singular($name)).'Repository';
22 22
 			if (class_exists($class)) 
23 23
 			{
24
-				\App::singleton($class, function ($app) use ($class) {
24
+				\App::singleton($class, function($app) use ($class) {
25 25
 
26 26
 					return new \App\Modules\Core\Decorators\CachingDecorator(new $class, $app['cache.store']);
27 27
 				});
Please login to merge, or discard this patch.
src/Modules/Core/Repositories/SettingRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 */
23 23
 	public function saveMany(array $data)
24 24
 	{
25
-		\DB::transaction(function () use ($data) {
25
+		\DB::transaction(function() use ($data) {
26 26
 			foreach ($data as $key => $value) 
27 27
 			{
28 28
 				$this->save($value);
Please login to merge, or discard this patch.
src/Modules/Core/Http/Controllers/BaseApiController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 		$this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
35 35
 		$this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
36 36
 		$this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
37
-		$route                     = explode('@',\Route::currentRouteAction())[1];
37
+		$route                     = explode('@', \Route::currentRouteAction())[1];
38 38
 
39
-		$this->middleware(function ($request, $next) {
39
+		$this->middleware(function($request, $next) {
40 40
             
41 41
 			$this->repo = call_user_func_array("\Core::{$this->model}", []);            
42 42
 			return $next($request);
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 
230 230
 			if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model)))
231 231
 			{}
232
-			elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) 
232
+			elseif ( ! $isPasswordClient && $user->tokenCan($this->model.'-'.$permission)) 
233 233
 			{}
234 234
 			else
235 235
 			{
Please login to merge, or discard this patch.
src/Modules/Core/Http/Controllers/SettingsController.php 1 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               = 'settings';
16
+	protected $model = 'settings';
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
 		'id'    => 'required|exists:settings,id',
25 25
 		'value' => 'required|string'
26 26
 	];
Please login to merge, or discard this patch.
src/Modules/Core/Utl/Media.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 	 */
12 12
 	public function uploadImage($image, $dir) 
13 13
 	{
14
-	   $imageName       =  str_slug('image' . uniqid() . time() . '_' . $image->getClientOriginalName());
15
-	   $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR;
14
+	   $imageName       = str_slug('image'.uniqid().time().'_'.$image->getClientOriginalName());
15
+	   $destinationPath = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR;
16 16
 
17 17
 	   ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false;
18 18
 	   $image->move($destinationPath, $imageName);
19 19
 
20
-	   return url($destinationPath . $imageName);
20
+	   return url($destinationPath.$imageName);
21 21
 	}
22 22
 
23 23
 	/**
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function uploadImageBas64($image, $dir) 
31 31
 	{
32
-		if (! strlen($image)) 
32
+		if ( ! strlen($image)) 
33 33
 		{
34 34
 			return null;
35 35
 		}
36 36
         
37
-		$imageName       = 'image' . uniqid() . time() . '.jpg';
38
-		$destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR;
37
+		$imageName       = 'image'.uniqid().time().'.jpg';
38
+		$destinationPath = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR;
39 39
 
40 40
 		! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false;
41 41
 
42
-		$base  = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image));
43
-		\Image::make($base)->save($destinationPath . $imageName);
42
+		$base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image));
43
+		\Image::make($base)->save($destinationPath.$imageName);
44 44
 
45
-		return url($destinationPath . $imageName);
45
+		return url($destinationPath.$imageName);
46 46
 	}
47 47
 
48 48
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	public function deleteImage($path, $dir) 
56 56
 	{   
57 57
 		$arr      = explode('/', $path);
58
-		$path     = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . end($arr);
58
+		$path     = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.end($arr);
59 59
 		if (\File::exists($path)) 
60 60
 		{
61 61
 			\File::delete($path);
Please login to merge, or discard this patch.