@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | Route::group([ |
55 | 55 | 'middleware' => 'web', |
56 | 56 | 'namespace' => $this->namespace, |
57 | - ], function ($router) { |
|
57 | + ], function($router) { |
|
58 | 58 | require module_path('reporting', 'Routes/web.php'); |
59 | 59 | }); |
60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'middleware' => 'api', |
73 | 73 | 'namespace' => $this->namespace, |
74 | 74 | 'prefix' => 'api', |
75 | - ], function ($router) { |
|
75 | + ], function($router) { |
|
76 | 76 | require module_path('reporting', 'Routes/api.php'); |
77 | 77 | }); |
78 | 78 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | Route::group([ |
55 | 55 | 'middleware' => 'web', |
56 | 56 | 'namespace' => $this->namespace, |
57 | - ], function ($router) { |
|
57 | + ], function($router) { |
|
58 | 58 | require module_path('acl', 'Routes/web.php'); |
59 | 59 | }); |
60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'middleware' => 'api', |
73 | 73 | 'namespace' => $this->namespace, |
74 | 74 | 'prefix' => 'api', |
75 | - ], function ($router) { |
|
75 | + ], function($router) { |
|
76 | 76 | require module_path('acl', 'Routes/api.php'); |
77 | 77 | }); |
78 | 78 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - DB::statement( "CREATE VIEW admin_count AS |
|
15 | + DB::statement("CREATE VIEW admin_count AS |
|
16 | 16 | select count(u.id) |
17 | 17 | from users u, groups g ,users_groups ug |
18 | 18 | where |
@@ -39,6 +39,6 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function down() |
41 | 41 | { |
42 | - DB::statement( "DROP VIEW IF EXISTS admin_count"); |
|
42 | + DB::statement("DROP VIEW IF EXISTS admin_count"); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
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 | 17 | $table->string('name', 100)->nullable(); |
18 | 18 | $table->string('email')->unique(); |
@@ -3,14 +3,14 @@ |
||
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) |
@@ -18,10 +18,10 @@ |
||
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\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
27 | 27 | }); |
@@ -12,10 +12,10 @@ |
||
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(); |
|
17 | + $table->string('name', 100); |
|
18 | + $table->string('key', 100)->unique(); |
|
19 | 19 | $table->text('value')->nullable(); |
20 | 20 | $table->softDeletes(); |
21 | 21 | $table->timestamps(); |
@@ -13,14 +13,14 @@ |
||
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 | 'name' => 'required|string|max:100', |
25 | 25 | 'value' => 'required|string' |
26 | 26 | ]; |
@@ -63,14 +63,14 @@ discard block |
||
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 | 70 | /** |
71 | 71 | * Use the first element in the model columns to construct the first condition. |
72 | 72 | */ |
73 | - $q->where(\DB::raw('LOWER(' . array_shift($conditionColumns) . ')'), 'LIKE', '%' . strtolower($query) . '%'); |
|
73 | + $q->where(\DB::raw('LOWER('.array_shift($conditionColumns).')'), 'LIKE', '%'.strtolower($query).'%'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | foreach ($conditionColumns as $column) |
80 | 80 | { |
81 | - $q->orWhere(\DB::raw('LOWER(' . $column . ')'), 'LIKE', '%' . strtolower($query) . '%'); |
|
81 | + $q->orWhere(\DB::raw('LOWER('.$column.')'), 'LIKE', '%'.strtolower($query).'%'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * Construct the relation condition. |
101 | 101 | */ |
102 | - $q->orWhereHas($relation, function ($subModel) use ($query, $relation){ |
|
102 | + $q->orWhereHas($relation, function($subModel) use ($query, $relation){ |
|
103 | 103 | |
104 | - $subModel->where(function ($q) use ($query, $relation){ |
|
104 | + $subModel->where(function($q) use ($query, $relation){ |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Get columns of the relation. |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * Use the first element in the relation model columns to construct the first condition. |
115 | 115 | */ |
116 | - $q->where(\DB::raw('LOWER(' . array_shift($subConditionColumns) . ')'), 'LIKE', '%' . strtolower($query) . '%'); |
|
116 | + $q->where(\DB::raw('LOWER('.array_shift($subConditionColumns).')'), 'LIKE', '%'.strtolower($query).'%'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | foreach ($subConditionColumns as $subConditionColumn) |
123 | 123 | { |
124 | - $q->orWhere(\DB::raw('LOWER(' . $subConditionColumn . ')'), 'LIKE', '%' . strtolower($query) . '%'); |
|
124 | + $q->orWhere(\DB::raw('LOWER('.$subConditionColumn.')'), 'LIKE', '%'.strtolower($query).'%'); |
|
125 | 125 | } |
126 | 126 | }); |
127 | 127 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $modelClass = $this->model; |
183 | 183 | $relations = []; |
184 | 184 | |
185 | - \DB::transaction(function () use (&$model, &$relations, $data, $saveLog, $modelClass) { |
|
185 | + \DB::transaction(function() use (&$model, &$relations, $data, $saveLog, $modelClass) { |
|
186 | 186 | /** |
187 | 187 | * If the id is present in the data then select the model for updating, |
188 | 188 | * else create new model. |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass; |
192 | 192 | if ( ! $model) |
193 | 193 | { |
194 | - \ErrorHandler::notFound(class_basename($modelClass) . ' with id : ' . $data['id']); |
|
194 | + \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | if ( ! $relationModel) |
251 | 251 | { |
252 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']); |
|
252 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * Prevent the sub relations or attributes not in the fillable. |
262 | 262 | */ |
263 | - if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
263 | + if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) |
|
264 | 264 | { |
265 | 265 | $relationModel->$attr = $val; |
266 | 266 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | if ( ! $relationModel) |
292 | 292 | { |
293 | - \ErrorHandler::notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']); |
|
293 | + \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | foreach ($value as $relationAttribute => $relationValue) |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | } |
436 | 436 | else |
437 | 437 | { |
438 | - call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){ |
|
438 | + call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($data, $saveLog){ |
|
439 | 439 | $model->update($data); |
440 | 440 | $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $model->id, $model) : false; |
441 | 441 | }); |
@@ -454,11 +454,11 @@ discard block |
||
454 | 454 | { |
455 | 455 | if ($attribute == 'id') |
456 | 456 | { |
457 | - \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) { |
|
457 | + \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) { |
|
458 | 458 | $model = $this->model->lockForUpdate()->find($value); |
459 | 459 | if ( ! $model) |
460 | 460 | { |
461 | - \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $value); |
|
461 | + \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | $model->delete(); |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | } |
468 | 468 | else |
469 | 469 | { |
470 | - \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) { |
|
471 | - call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($saveLog){ |
|
470 | + \DB::transaction(function() use ($value, $attribute, &$result, $saveLog) { |
|
471 | + call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function($model) use ($saveLog){ |
|
472 | 472 | $model->delete(); |
473 | 473 | $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $model->id, $model) : false; |
474 | 474 | }); |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | { |
506 | 506 | $conditions = $this->constructConditions($conditions, $this->model); |
507 | 507 | $sort = $desc ? 'desc' : 'asc'; |
508 | - return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns); |
|
508 | + return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
546 | 546 | } |
547 | 547 | |
548 | - return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);; |
|
548 | + return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns); ; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | |
561 | 561 | if ( ! $model) |
562 | 562 | { |
563 | - \ErrorHandler::notFound(class_basename($this->model) . ' with id : ' . $id); |
|
563 | + \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | $model->restore(); |
@@ -580,13 +580,13 @@ discard block |
||
580 | 580 | if ($key == 'and') |
581 | 581 | { |
582 | 582 | $conditions = $this->constructConditions($value, $model); |
583 | - $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
|
583 | + $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} '; |
|
584 | 584 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
585 | 585 | } |
586 | 586 | else if ($key == 'or') |
587 | 587 | { |
588 | 588 | $conditions = $this->constructConditions($value, $model); |
589 | - $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
|
589 | + $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} '; |
|
590 | 590 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
591 | 591 | } |
592 | 592 | else |
@@ -611,41 +611,41 @@ discard block |
||
611 | 611 | |
612 | 612 | if (strtolower($operator) == 'between') |
613 | 613 | { |
614 | - $conditionString .= $key . ' >= ? and '; |
|
614 | + $conditionString .= $key.' >= ? and '; |
|
615 | 615 | $conditionValues[] = $value1; |
616 | 616 | |
617 | - $conditionString .= $key . ' <= ? {op} '; |
|
617 | + $conditionString .= $key.' <= ? {op} '; |
|
618 | 618 | $conditionValues[] = $value2; |
619 | 619 | } |
620 | 620 | elseif (strtolower($operator) == 'in') |
621 | 621 | { |
622 | 622 | $conditionValues = array_merge($conditionValues, $value); |
623 | 623 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
624 | - $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
|
624 | + $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} '; |
|
625 | 625 | } |
626 | 626 | elseif (strtolower($operator) == 'null') |
627 | 627 | { |
628 | - $conditionString .= $key . ' is null {op} '; |
|
628 | + $conditionString .= $key.' is null {op} '; |
|
629 | 629 | } |
630 | 630 | elseif (strtolower($operator) == 'not null') |
631 | 631 | { |
632 | - $conditionString .= $key . ' is not null {op} '; |
|
632 | + $conditionString .= $key.' is not null {op} '; |
|
633 | 633 | } |
634 | 634 | elseif (strtolower($operator) == 'has') |
635 | 635 | { |
636 | 636 | $sql = $model->withTrashed()->has($key)->toSql(); |
637 | 637 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
638 | - $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
|
638 | + $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].') {op} '; |
|
639 | 639 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
640 | 640 | } |
641 | 641 | else |
642 | 642 | { |
643 | - $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
|
643 | + $conditionString .= $key.' '.$operator.' ? {op} '; |
|
644 | 644 | $conditionValues[] = $value; |
645 | 645 | } |
646 | 646 | } |
647 | 647 | } |
648 | - $conditionString = '(' . rtrim($conditionString, '{op} ') . ')'; |
|
648 | + $conditionString = '('.rtrim($conditionString, '{op} ').')'; |
|
649 | 649 | return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues]; |
650 | 650 | } |
651 | 651 |