@@ -18,14 +18,14 @@ |
||
| 18 | 18 | public function __call($name, $arguments) |
| 19 | 19 | { |
| 20 | 20 | foreach (\Module::all() as $module) { |
| 21 | - $nameSpace = 'App\\Modules\\' . $module['basename'] ; |
|
| 21 | + $nameSpace = 'App\\Modules\\'.$module['basename']; |
|
| 22 | 22 | $model = ucfirst(\Str::singular($name)); |
| 23 | - $class = $nameSpace . '\\Repositories\\' . $model . 'Repository'; |
|
| 24 | - $decoratedClass = $class . '\\Decorated'; |
|
| 23 | + $class = $nameSpace.'\\Repositories\\'.$model.'Repository'; |
|
| 24 | + $decoratedClass = $class.'\\Decorated'; |
|
| 25 | 25 | |
| 26 | 26 | if (class_exists($class)) { |
| 27 | 27 | $classObj = \App::make($class); |
| 28 | - \App::singleton($class, function ($app) use ($classObj) { |
|
| 28 | + \App::singleton($class, function($app) use ($classObj) { |
|
| 29 | 29 | return new CachingDecorator($classObj, $app['cache.store']); |
| 30 | 30 | }); |
| 31 | 31 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct($model) |
| 23 | 23 | { |
| 24 | - $this->model = $model; |
|
| 24 | + $this->model = $model; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * Construct the select conditions for the model. |
| 62 | 62 | */ |
| 63 | - $model->where(function ($q) use ($query, $conditionColumns, $relations) { |
|
| 63 | + $model->where(function($q) use ($query, $conditionColumns, $relations) { |
|
| 64 | 64 | |
| 65 | 65 | if (count($conditionColumns)) { |
| 66 | 66 | $column = 'LOWER('.array_shift($conditionColumns).')'; |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | /** |
| 103 | 103 | * Construct the relation condition. |
| 104 | 104 | */ |
| 105 | - $q->orWhereHas($relation, function ($subModel) use ($query, $relation) { |
|
| 105 | + $q->orWhereHas($relation, function($subModel) use ($query, $relation) { |
|
| 106 | 106 | |
| 107 | - $subModel->where(function ($q) use ($query, $relation) { |
|
| 107 | + $subModel->where(function($q) use ($query, $relation) { |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Get columns of the relation. |
@@ -192,14 +192,14 @@ discard block |
||
| 192 | 192 | $modelClass = $this->model; |
| 193 | 193 | $relations = []; |
| 194 | 194 | |
| 195 | - \DB::transaction(function () use (&$model, &$relations, $data, $modelClass) { |
|
| 195 | + \DB::transaction(function() use (&$model, &$relations, $data, $modelClass) { |
|
| 196 | 196 | /** |
| 197 | 197 | * If the id is present in the data then select the model for updating, |
| 198 | 198 | * else create new model. |
| 199 | 199 | * @var array |
| 200 | 200 | */ |
| 201 | 201 | $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass; |
| 202 | - if (! $model) { |
|
| 202 | + if ( ! $model) { |
|
| 203 | 203 | \ErrorHandler::notFound(class_basename($modelClass).' with id : '.$data['id']); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * If the relation has no value then marke the relation data |
| 223 | 223 | * related to the model to be deleted. |
| 224 | 224 | */ |
| 225 | - if (! $value || ! count($value)) { |
|
| 225 | + if ( ! $value || ! count($value)) { |
|
| 226 | 226 | $relations[$relation] = 'delete'; |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | /** |
| 250 | 250 | * If model doesn't exists. |
| 251 | 251 | */ |
| 252 | - if (! $relationModel) { |
|
| 252 | + if ( ! $relationModel) { |
|
| 253 | 253 | \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$val['id']); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | /** |
| 281 | 281 | * If model doesn't exists. |
| 282 | 282 | */ |
| 283 | - if (! $relationModel) { |
|
| 283 | + if ( ! $relationModel) { |
|
| 284 | 284 | \ErrorHandler::notFound(class_basename($relationBaseModel).' with id : '.$value['id']); |
| 285 | 285 | } |
| 286 | 286 | |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $model = $this->model->lockForUpdate()->find($value); |
| 418 | 418 | $model ? $model->update($data) : 0; |
| 419 | 419 | } else { |
| 420 | - $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) use ($data) { |
|
| 420 | + $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function($model) use ($data) { |
|
| 421 | 421 | $model->update($data); |
| 422 | 422 | }); |
| 423 | 423 | } |
@@ -434,17 +434,17 @@ discard block |
||
| 434 | 434 | public function delete($value, $attribute = 'id') |
| 435 | 435 | { |
| 436 | 436 | if ($attribute == 'id') { |
| 437 | - \DB::transaction(function () use ($value) { |
|
| 437 | + \DB::transaction(function() use ($value) { |
|
| 438 | 438 | $model = $this->model->lockForUpdate()->find($value); |
| 439 | - if (! $model) { |
|
| 439 | + if ( ! $model) { |
|
| 440 | 440 | \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value); |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | $model->delete(); |
| 444 | 444 | }); |
| 445 | 445 | } else { |
| 446 | - \DB::transaction(function () use ($value, $attribute) { |
|
| 447 | - $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) { |
|
| 446 | + \DB::transaction(function() use ($value, $attribute) { |
|
| 447 | + $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function($model) { |
|
| 448 | 448 | $model->delete(); |
| 449 | 449 | }); |
| 450 | 450 | }); |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | { |
| 533 | 533 | $model = $this->model->onlyTrashed()->find($id); |
| 534 | 534 | |
| 535 | - if (! $model) { |
|
| 535 | + if ( ! $model) { |
|
| 536 | 536 | \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id); |
| 537 | 537 | } |
| 538 | 538 | |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | $value = $removeLast === false ? $value : substr($value, 0, $removeLast); |
| 616 | 616 | $path = explode('->', $value); |
| 617 | 617 | $field = array_shift($path); |
| 618 | - $result = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) { |
|
| 618 | + $result = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) { |
|
| 619 | 619 | return '"'.$part.'"'; |
| 620 | 620 | })->implode('.')); |
| 621 | 621 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $permissions = []; |
| 29 | 29 | $user = $this->find(\Auth::id(), $relations); |
| 30 | 30 | foreach ($user->groups()->get() as $group) { |
| 31 | - $group->permissions->each(function ($permission) use (&$permissions) { |
|
| 31 | + $group->permissions->each(function($permission) use (&$permissions) { |
|
| 32 | 32 | $permissions[$permission->model][$permission->id] = $permission->name; |
| 33 | 33 | }); |
| 34 | 34 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
| 52 | 52 | $permissions = []; |
| 53 | 53 | |
| 54 | - $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model) { |
|
| 54 | + $user->groups->pluck('permissions')->each(function($permission) use (&$permissions, $model) { |
|
| 55 | 55 | $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
| 56 | 56 | }); |
| 57 | 57 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function assignGroups($userId, $groupIds) |
| 82 | 82 | { |
| 83 | - \DB::transaction(function () use ($userId, $groupIds) { |
|
| 83 | + \DB::transaction(function() use ($userId, $groupIds) { |
|
| 84 | 84 | $user = $this->find($userId); |
| 85 | 85 | $user->groups()->detach(); |
| 86 | 86 | $user->groups()->attach($groupIds); |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function login($credentials, $adminLogin = false) |
| 101 | 101 | { |
| 102 | - if (! $user = $this->first(['email' => $credentials['email']])) { |
|
| 102 | + if ( ! $user = $this->first(['email' => $credentials['email']])) { |
|
| 103 | 103 | \ErrorHandler::loginFailed(); |
| 104 | 104 | } elseif ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) { |
| 105 | 105 | \ErrorHandler::loginFailed(); |
| 106 | - } elseif (! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) { |
|
| 106 | + } elseif ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) { |
|
| 107 | 107 | \ErrorHandler::loginFailed(); |
| 108 | 108 | } elseif ($user->blocked) { |
| 109 | 109 | \ErrorHandler::userIsBlocked(); |
| 110 | - } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
| 110 | + } elseif ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
| 111 | 111 | \ErrorHandler::emailNotConfirmed(); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken; |
| 128 | 128 | $user = \Socialite::driver($type)->userFromToken($access_token); |
| 129 | 129 | |
| 130 | - if (! $user->email) { |
|
| 130 | + if ( ! $user->email) { |
|
| 131 | 131 | \ErrorHandler::noSocialEmail(); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | if ($skipConfirmEmail) { |
| 154 | 154 | $user->confirmed = 1; |
| 155 | 155 | $user->save(); |
| 156 | - } elseif (! config('skeleton.disable_confirm_email')) { |
|
| 156 | + } elseif ( ! config('skeleton.disable_confirm_email')) { |
|
| 157 | 157 | $this->sendConfirmationEmail($user->email); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function block($userId) |
| 170 | 170 | { |
| 171 | - if (! $user = $this->find($userId)) { |
|
| 171 | + if ( ! $user = $this->find($userId)) { |
|
| 172 | 172 | \ErrorHandler::notFound('user'); |
| 173 | 173 | } |
| 174 | - if (! $this->hasGroup(['Admin'])) { |
|
| 174 | + if ( ! $this->hasGroup(['Admin'])) { |
|
| 175 | 175 | \ErrorHandler::noPermissions(); |
| 176 | 176 | } elseif (\Auth::id() == $userId) { |
| 177 | 177 | \ErrorHandler::noPermissions(); |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function unblock($userId) |
| 195 | 195 | { |
| 196 | - if (! $this->hasGroup(['Admin'])) { |
|
| 196 | + if ( ! $this->hasGroup(['Admin'])) { |
|
| 197 | 197 | \ErrorHandler::noPermissions(); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function sendReset($email) |
| 214 | 214 | { |
| 215 | - if (! $user = $this->model->where('email', $email)->first()) { |
|
| 215 | + if ( ! $user = $this->model->where('email', $email)->first()) { |
|
| 216 | 216 | \ErrorHandler::notFound('email'); |
| 217 | 217 | } |
| 218 | 218 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function resetPassword($credentials) |
| 230 | 230 | { |
| 231 | - $response = \Password::reset($credentials, function ($user, $password) { |
|
| 231 | + $response = \Password::reset($credentials, function($user, $password) { |
|
| 232 | 232 | $user->password = $password; |
| 233 | 233 | $user->save(); |
| 234 | 234 | }); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | public function changePassword($credentials) |
| 264 | 264 | { |
| 265 | 265 | $user = \Auth::user(); |
| 266 | - if (! \Hash::check($credentials['old_password'], $user->password)) { |
|
| 266 | + if ( ! \Hash::check($credentials['old_password'], $user->password)) { |
|
| 267 | 267 | \ErrorHandler::invalidOldPassword(); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public function confirmEmail($confirmationCode) |
| 281 | 281 | { |
| 282 | - if (! $user = $this->first(['confirmation_code' => $confirmationCode])) { |
|
| 282 | + if ( ! $user = $this->first(['confirmation_code' => $confirmationCode])) { |
|
| 283 | 283 | \ErrorHandler::invalidConfirmationCode(); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $sort = $desc ? 'desc' : 'asc'; |
| 325 | 325 | $model = $this->model->with($relations); |
| 326 | 326 | |
| 327 | - $model->whereHas('groups', function ($q) use ($groupName) { |
|
| 327 | + $model->whereHas('groups', function($q) use ($groupName) { |
|
| 328 | 328 | $q->where('name', $groupName); |
| 329 | 329 | }); |
| 330 | 330 | |