@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function toArray($request) |
| 19 | 19 | { |
| 20 | - if (! $this->resource) { |
|
| 20 | + if ( ! $this->resource) { |
|
| 21 | 21 | return []; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -47,9 +47,9 @@ |
||
| 47 | 47 | /** |
| 48 | 48 | * Check report existance and permission. |
| 49 | 49 | */ |
| 50 | - if (! $report) { |
|
| 50 | + if ( ! $report) { |
|
| 51 | 51 | Errors::notFound('report'); |
| 52 | - } elseif (! $skipPermission && ! $this->userService->can($report->view_name, 'report')) { |
|
| 52 | + } elseif ( ! $skipPermission && ! $this->userService->can($report->view_name, 'report')) { |
|
| 53 | 53 | Errors::noPermissions(); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function revoke(int $clientId): Model |
| 30 | 30 | { |
| 31 | - return DB::transaction(function () use ($clientId) { |
|
| 31 | + return DB::transaction(function() use ($clientId) { |
|
| 32 | 32 | $client = $this->repo->find($clientId); |
| 33 | 33 | $this->repo->revokeClientTokens($client); |
| 34 | 34 | return $this->repo->save(['id'=> $clientId, 'revoked' => true]); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $permissions = []; |
| 75 | 75 | $user = $this->repo->find(Auth::id(), $relations); |
| 76 | 76 | foreach ($user->roles as $role) { |
| 77 | - $role->permissions->each(function ($permission) use (&$permissions) { |
|
| 77 | + $role->permissions->each(function($permission) use (&$permissions) { |
|
| 78 | 78 | $permissions[] = $permission; |
| 79 | 79 | }); |
| 80 | 80 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | public function assignRoles(int $userId, array $roleIds): Model |
| 138 | 138 | { |
| 139 | 139 | $user = new Model(); |
| 140 | - DB::transaction(function () use ($userId, $roleIds, &$user) { |
|
| 140 | + DB::transaction(function() use ($userId, $roleIds, &$user) { |
|
| 141 | 141 | $user = $this->repo->find($userId); |
| 142 | 142 | $this->repo->detachRoles($user); |
| 143 | 143 | $this->repo->attachRoles($user, $roleIds); |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function login(string $email, string $password): array |
| 157 | 157 | { |
| 158 | - if (!$user = $this->repo->first(['email' => $email])) { |
|
| 158 | + if ( ! $user = $this->repo->first(['email' => $email])) { |
|
| 159 | 159 | Errors::loginFailed(); |
| 160 | 160 | } elseif ($user->blocked) { |
| 161 | 161 | Errors::userIsBlocked(); |
| 162 | - } elseif (!config('user.disable_confirm_email') && !$user->confirmed) { |
|
| 162 | + } elseif ( ! config('user.disable_confirm_email') && ! $user->confirmed) { |
|
| 163 | 163 | Errors::emailNotConfirmed(); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | $accessToken = $authCode ? Arr::get(Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken; |
| 180 | 180 | $user = Socialite::driver($type)->userFromToken($accessToken)->user; |
| 181 | 181 | |
| 182 | - if (!Arr::has($user, 'email')) { |
|
| 182 | + if ( ! Arr::has($user, 'email')) { |
|
| 183 | 183 | Errors::noSocialEmail(); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if (!$this->repo->first(['email' => $user['email']]) && !$this->repo->deleted(['email' => $user['email']])->total()) { |
|
| 186 | + if ( ! $this->repo->first(['email' => $user['email']]) && ! $this->repo->deleted(['email' => $user['email']])->total()) { |
|
| 187 | 187 | $this->register(Arr::get($user, 'name'), $user['email'], '', true); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | $user = $this->repo->save($data); |
| 210 | 210 | |
| 211 | - if (!$skipConfirmEmail && !config('user.disable_confirm_email')) { |
|
| 211 | + if ( ! $skipConfirmEmail && ! config('user.disable_confirm_email')) { |
|
| 212 | 212 | $this->sendConfirmationEmail($user->email); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function sendReset(string $email): bool |
| 251 | 251 | { |
| 252 | - if (!$user = $this->repo->first(['email' => $email])) { |
|
| 252 | + if ( ! $user = $this->repo->first(['email' => $email])) { |
|
| 253 | 253 | Errors::notFound('email'); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | 'password' => $password, |
| 276 | 276 | 'password_confirmation' => $passwordConfirmation, |
| 277 | 277 | 'token' => $token |
| 278 | - ], function ($user, $password) { |
|
| 278 | + ], function($user, $password) { |
|
| 279 | 279 | $this->repo->save(['id' => $user->id, 'password' => $password]); |
| 280 | 280 | }); |
| 281 | 281 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | public function changePassword(string $password, string $oldPassword): bool |
| 305 | 305 | { |
| 306 | 306 | $user = Auth::user(); |
| 307 | - if (!Hash::check($oldPassword, $user->password)) { |
|
| 307 | + if ( ! Hash::check($oldPassword, $user->password)) { |
|
| 308 | 308 | Errors::invalidOldPassword(); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function confirmEmail(string $confirmationCode): bool |
| 323 | 323 | { |
| 324 | - if (!$user = $this->repo->first(['confirmation_code' => $confirmationCode])) { |
|
| 324 | + if ( ! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) { |
|
| 325 | 325 | Errors::invalidConfirmationCode(); |
| 326 | 326 | } |
| 327 | 327 | |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | $permission = $routeActions[1]; |
| 58 | 58 | |
| 59 | 59 | $this->auth->shouldUse('api'); |
| 60 | - if (! in_array($permission, $skipLoginCheck)) { |
|
| 61 | - $this->authMiddleware->handle($request, function ($request) use ($modelName, $skipPermissionCheck, $permission) { |
|
| 60 | + if ( ! in_array($permission, $skipLoginCheck)) { |
|
| 61 | + $this->authMiddleware->handle($request, function($request) use ($modelName, $skipPermissionCheck, $permission) { |
|
| 62 | 62 | $user = $this->auth->user(); |
| 63 | 63 | $isPasswordClient = $user->token() ? $user->token()->client->password_client : false; |
| 64 | 64 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | if ($isPasswordClient && (in_array($permission, $skipPermissionCheck) || $this->userService->can($permission, $modelName))) { |
| 70 | - } elseif (! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) { |
|
| 70 | + } elseif ( ! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) { |
|
| 71 | 71 | } else { |
| 72 | 72 | Errors::noPermissions(); |
| 73 | 73 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $translatable = $this->repo->model->translatable ?? []; |
| 44 | 44 | $filters = $this->constructFilters($conditions, $local); |
| 45 | - $sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . $local : $sortBy; |
|
| 45 | + $sortBy = in_array($sortBy, $translatable) ? $sortBy.'->'.$local : $sortBy; |
|
| 46 | 46 | |
| 47 | 47 | if ($trashed) { |
| 48 | 48 | return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true); |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | /** |
| 214 | 214 | * Prepare key based on the the requested lang if it was translatable. |
| 215 | 215 | */ |
| 216 | - $key = in_array($key, $translatable) ? $key . '->' . $local : $key; |
|
| 216 | + $key = in_array($key, $translatable) ? $key.'->'.$local : $key; |
|
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | 219 | * Convert 0/1 or true/false to boolean in case of not foreign key. |
| 220 | 220 | */ |
| 221 | - if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null && strpos($key, '_id') === false && !is_null($value)) { |
|
| 221 | + if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null && strpos($key, '_id') === false && ! is_null($value)) { |
|
| 222 | 222 | $filters[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN); |
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | 225 | * Use in operator in case of foreign and comma seperated values. |
| 226 | 226 | */ |
| 227 | - } elseif (!is_array($value) && strpos($key, '_id') && $value) { |
|
| 227 | + } elseif ( ! is_array($value) && strpos($key, '_id') && $value) { |
|
| 228 | 228 | $filters[$key] = [ |
| 229 | 229 | 'op' => 'in', |
| 230 | 230 | 'val' => explode(',', $value) |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | * Default string filteration. |
| 249 | 249 | */ |
| 250 | 250 | } elseif ($value) { |
| 251 | - $key = 'LOWER(' . $key . ')'; |
|
| 251 | + $key = 'LOWER('.$key.')'; |
|
| 252 | 252 | $value = strtolower($value); |
| 253 | 253 | $filters[$key] = [ |
| 254 | 254 | 'op' => 'like', |
| 255 | - 'val' => '%' . $value . '%' |
|
| 255 | + 'val' => '%'.$value.'%' |
|
| 256 | 256 | ]; |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -54,8 +54,8 @@ |
||
| 54 | 54 | public static function toString() |
| 55 | 55 | { |
| 56 | 56 | $stringArr = []; |
| 57 | - collect(self::all())->each(function ($item, $key) use (&$stringArr) { |
|
| 58 | - $stringArr[] = $key . ': ' . $item; |
|
| 57 | + collect(self::all())->each(function($item, $key) use (&$stringArr) { |
|
| 58 | + $stringArr[] = $key.': '.$item; |
|
| 59 | 59 | }); |
| 60 | 60 | |
| 61 | 61 | return implode(',', $stringArr); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $this->container['slug'] = Str::slug($this->argument('slug')); |
| 92 | 92 | $this->container['name'] = Str::studly($this->container['slug']); |
| 93 | 93 | $this->container['version'] = '1.0'; |
| 94 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
| 94 | + $this->container['description'] = 'This is the description for the '.$this->container['name'].' module.'; |
|
| 95 | 95 | $this->container['location'] = config('modules.default_location'); |
| 96 | 96 | $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
| 97 | 97 | $this->container['basename'] = Str::studly($this->container['slug']); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $progress->finish(); |
| 126 | 126 | |
| 127 | - event($this->container['slug'] . '.module.made'); |
|
| 127 | + event($this->container['slug'].'.module.made'); |
|
| 128 | 128 | |
| 129 | 129 | $this->info("\nModule generated successfully."); |
| 130 | 130 | } |
@@ -139,18 +139,18 @@ discard block |
||
| 139 | 139 | $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
| 140 | 140 | $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
| 141 | 141 | |
| 142 | - if (!$this->files->isDirectory($root)) { |
|
| 142 | + if ( ! $this->files->isDirectory($root)) { |
|
| 143 | 143 | $this->files->makeDirectory($root); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $directory = module_path(null, $this->container['basename'], $location); |
| 147 | - $source = __DIR__ . '/Stubs/Module'; |
|
| 147 | + $source = __DIR__.'/Stubs/Module'; |
|
| 148 | 148 | |
| 149 | 149 | $this->files->makeDirectory($directory); |
| 150 | 150 | |
| 151 | 151 | $sourceFiles = $this->files->allFiles($source, true); |
| 152 | 152 | |
| 153 | - if (!empty($this->mapping)) { |
|
| 153 | + if ( ! empty($this->mapping)) { |
|
| 154 | 154 | $search = array_keys($this->mapping); |
| 155 | 155 | $replace = array_values($this->mapping); |
| 156 | 156 | } |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | $contents = $this->replacePlaceholders($file->getContents()); |
| 160 | 160 | $subPath = $file->getRelativePathname(); |
| 161 | 161 | |
| 162 | - if (!empty($this->mapping)) { |
|
| 162 | + if ( ! empty($this->mapping)) { |
|
| 163 | 163 | $subPath = str_replace($search, $replace, $subPath); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $filePath = $directory . '/' . $subPath; |
|
| 166 | + $filePath = $directory.'/'.$subPath; |
|
| 167 | 167 | |
| 168 | 168 | // if the file is module.json, replace it with the custom manifest file name |
| 169 | 169 | if ($file->getFilename() === 'module.json' && $manifest) { |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $dir = dirname($filePath); |
| 180 | 180 | |
| 181 | - if (! $this->files->isDirectory($dir)) { |
|
| 181 | + if ( ! $this->files->isDirectory($dir)) { |
|
| 182 | 182 | $this->files->makeDirectory($dir, 0755, true); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -213,22 +213,22 @@ discard block |
||
| 213 | 213 | ]; |
| 214 | 214 | |
| 215 | 215 | $replace = [ |
| 216 | - ucfirst($modelNameSingular) . 'Factory', |
|
| 216 | + ucfirst($modelNameSingular).'Factory', |
|
| 217 | 217 | $modelNameSingular, |
| 218 | 218 | $this->container['slug'], |
| 219 | 219 | ucfirst($modelName), |
| 220 | 220 | ucfirst($modelNameSingular), |
| 221 | - ucfirst($modelName) . 'DatabaseSeeder', |
|
| 222 | - ucfirst($modelName) . 'TableSeeder', |
|
| 223 | - ucfirst($modelNameSingular) . 'Controller', |
|
| 224 | - ucfirst($modelNameSingular) . 'Service', |
|
| 225 | - ucfirst($modelNameSingular) . 'ServiceInterface', |
|
| 226 | - ucfirst($modelNameSingular) . 'Repository', |
|
| 227 | - ucfirst($modelNameSingular) . 'RepositoryInterface', |
|
| 228 | - ucfirst($modelName) . 'Errors', |
|
| 229 | - 'Store' . ucfirst($modelNameSingular), |
|
| 221 | + ucfirst($modelName).'DatabaseSeeder', |
|
| 222 | + ucfirst($modelName).'TableSeeder', |
|
| 223 | + ucfirst($modelNameSingular).'Controller', |
|
| 224 | + ucfirst($modelNameSingular).'Service', |
|
| 225 | + ucfirst($modelNameSingular).'ServiceInterface', |
|
| 226 | + ucfirst($modelNameSingular).'Repository', |
|
| 227 | + ucfirst($modelNameSingular).'RepositoryInterface', |
|
| 228 | + ucfirst($modelName).'Errors', |
|
| 229 | + 'Store'.ucfirst($modelNameSingular), |
|
| 230 | 230 | ucfirst($modelNameSingular), |
| 231 | - ucfirst($modelNameSingular) . 'Observer', |
|
| 231 | + ucfirst($modelNameSingular).'Observer', |
|
| 232 | 232 | Str::snake($modelName), |
| 233 | 233 | $modelName, |
| 234 | 234 | ]; |
@@ -252,6 +252,6 @@ discard block |
||
| 252 | 252 | $modelName = $this->container['slug']; |
| 253 | 253 | $migrationName = Str::camel($modelName); |
| 254 | 254 | $migrationName = Str::snake($migrationName); |
| 255 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $migrationName . '_table']); |
|
| 255 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_'.$migrationName.'_table']); |
|
| 256 | 256 | } |
| 257 | 257 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | public function saveMany(array $data): void |
| 29 | 29 | { |
| 30 | - DB::transaction(function () use ($data) { |
|
| 30 | + DB::transaction(function() use ($data) { |
|
| 31 | 31 | foreach ($data as $value) { |
| 32 | 32 | $this->repo->save($value); |
| 33 | 33 | } |