@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | return $this->readJson(); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () { |
|
| 82 | + return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function() { |
|
| 83 | 83 | return $this->readJson(); |
| 84 | 84 | }); |
| 85 | 85 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function config(string $key, $default = null) |
| 103 | 103 | { |
| 104 | - return $this->config->get('modules.activators.file.' . $key, $default); |
|
| 104 | + return $this->config->get('modules.activators.file.'.$key, $default); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function getCachedServicesPath(): string |
| 17 | 17 | { |
| 18 | - return Str::replaceLast('services.php', $this->getSnakeName() . '_module.php', $this->app->getCachedServicesPath()); |
|
| 18 | + return Str::replaceLast('services.php', $this->getSnakeName().'_module.php', $this->app->getCachedServicesPath()); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function getCachedServicesPath(): string |
| 14 | 14 | { |
| 15 | - return Str::replaceLast('services.php', $this->getSnakeName() . '_module.php', $this->app->basePath('storage/app/') . 'services.php'); |
|
| 15 | + return Str::replaceLast('services.php', $this->getSnakeName().'_module.php', $this->app->basePath('storage/app/').'services.php'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function createField($column, $attributes, $type = 'add') |
| 148 | 148 | { |
| 149 | - $results = "\t\t\t" . '$table'; |
|
| 149 | + $results = "\t\t\t".'$table'; |
|
| 150 | 150 | |
| 151 | 151 | foreach ($attributes as $key => $field) { |
| 152 | 152 | if (in_array($column, $this->relationshipKeys)) { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - return $results . ';' . PHP_EOL; |
|
| 159 | + return $results.';'.PHP_EOL; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | protected function addRelationColumn($key, $field, $column) |
| 172 | 172 | { |
| 173 | 173 | if ($key === 0) { |
| 174 | - $relatedColumn = Str::snake(class_basename($field)) . '_id'; |
|
| 174 | + $relatedColumn = Str::snake(class_basename($field)).'_id'; |
|
| 175 | 175 | |
| 176 | - return "->integer('{$relatedColumn}')->unsigned();" . PHP_EOL . "\t\t\t" . "\$table->foreign('{$relatedColumn}')"; |
|
| 176 | + return "->integer('{$relatedColumn}')->unsigned();".PHP_EOL."\t\t\t"."\$table->foreign('{$relatedColumn}')"; |
|
| 177 | 177 | } |
| 178 | 178 | if ($key === 1) { |
| 179 | 179 | return "->references('{$field}')"; |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | return "->on('{$field}')"; |
| 183 | 183 | } |
| 184 | 184 | if (Str::contains($field, '(')) { |
| 185 | - return '->' . $field; |
|
| 185 | + return '->'.$field; |
|
| 186 | 186 | } |
| 187 | - return '->' . $field . '()'; |
|
| 187 | + return '->'.$field.'()'; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -199,18 +199,18 @@ discard block |
||
| 199 | 199 | protected function addColumn($key, $field, $column) |
| 200 | 200 | { |
| 201 | 201 | if ($this->hasCustomAttribute($column)) { |
| 202 | - return '->' . $field; |
|
| 202 | + return '->'.$field; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | if ($key == 0) { |
| 206 | - return '->' . $field . "('" . $column . "')"; |
|
| 206 | + return '->'.$field."('".$column."')"; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | if (Str::contains($field, '(')) { |
| 210 | - return '->' . $field; |
|
| 210 | + return '->'.$field; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - return '->' . $field . '()'; |
|
| 213 | + return '->'.$field.'()'; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -225,10 +225,10 @@ discard block |
||
| 225 | 225 | protected function removeColumn($key, $field, $column) |
| 226 | 226 | { |
| 227 | 227 | if ($this->hasCustomAttribute($column)) { |
| 228 | - return '->' . $field; |
|
| 228 | + return '->'.$field; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - return '->dropColumn(' . "'" . $column . "')"; |
|
| 231 | + return '->dropColumn('."'".$column."')"; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public function getAttributes($column, $schema) |
| 255 | 255 | { |
| 256 | - $fields = str_replace($column . ':', '', $schema); |
|
| 256 | + $fields = str_replace($column.':', '', $schema); |
|
| 257 | 257 | |
| 258 | 258 | return $this->hasCustomAttribute($column) ? $this->getCustomAttribute($column) : explode(':', $fields); |
| 259 | 259 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @param $name |
| 246 | 246 | * |
| 247 | - * @return mixed |
|
| 247 | + * @return Module |
|
| 248 | 248 | * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException |
| 249 | 249 | */ |
| 250 | 250 | public function findOrFail(string $name) |
@@ -417,9 +417,7 @@ discard block |
||
| 417 | 417 | /** |
| 418 | 418 | * Creates a new Module instance |
| 419 | 419 | * |
| 420 | - * @param Container $app |
|
| 421 | - * @param string $args |
|
| 422 | - * @param string $path |
|
| 420 | + * @param string[] $args |
|
| 423 | 421 | * @return \Nwidart\Modules\Module |
| 424 | 422 | */ |
| 425 | 423 | abstract protected function createModule(...$args); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function getCached() |
| 98 | 98 | { |
| 99 | - return $this->cache->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () { |
|
| 99 | + return $this->cache->remember($this->config('cache.key'), $this->config('cache.lifetime'), function() { |
|
| 100 | 100 | return $this->toCollection()->toArray(); |
| 101 | 101 | }); |
| 102 | 102 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function getModulePath($name) |
| 280 | 280 | { |
| 281 | - return $this->getPath() . '/' . $name; |
|
| 281 | + return $this->getPath().'/'.$name; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | public function config(string $key, $default = null) |
| 301 | 301 | { |
| 302 | - return $this->config->get('modules.' . $key, $default); |
|
| 302 | + return $this->config->get('modules.'.$key, $default); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | public function assetPath(string $module): string |
| 359 | 359 | { |
| 360 | - return $this->config('paths.assets') . '/' . $module; |
|
| 360 | + return $this->config('paths.assets').'/'.$module; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @param string $name |
| 39 | 39 | * @param string $path |
| 40 | - * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model |
|
| 40 | + * @return boolean |
|
| 41 | 41 | */ |
| 42 | 42 | public static function findByNameOrCreate(string $name, string $path) |
| 43 | 43 | { |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | - * @param $column |
|
| 58 | - * @param $direction |
|
| 57 | + * @param string $column |
|
| 58 | + * @param string $direction |
|
| 59 | 59 | * @return \Illuminate\Database\Eloquent\Builder |
| 60 | 60 | */ |
| 61 | 61 | public static function orderBy($column, $direction) |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | protected function registerNamespaces() |
| 38 | 38 | { |
| 39 | - $configPath = __DIR__ . '/../config/config.php'; |
|
| 39 | + $configPath = __DIR__.'/../config/config.php'; |
|
| 40 | 40 | |
| 41 | 41 | $this->mergeConfigFrom($configPath, 'modules'); |
| 42 | 42 | $this->publishes([ |
@@ -73,6 +73,6 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function registerMigrations() |
| 75 | 75 | { |
| 76 | - $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
|
| 76 | + $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
| 77 | 77 | } |
| 78 | 78 | } |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function setupStubPath() |
| 39 | 39 | { |
| 40 | - Stub::setBasePath(__DIR__ . '/Commands/stubs'); |
|
| 40 | + Stub::setBasePath(__DIR__.'/Commands/stubs'); |
|
| 41 | 41 | |
| 42 | - $this->app->booted(function ($app) { |
|
| 42 | + $this->app->booted(function($app) { |
|
| 43 | 43 | /** @var RepositoryInterface $moduleRepository */ |
| 44 | 44 | $moduleRepository = $app[RepositoryInterface::class]; |
| 45 | 45 | if ($moduleRepository->config('stubs.enabled') === true) { |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | protected function registerServices() |
| 55 | 55 | { |
| 56 | - $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) { |
|
| 56 | + $this->app->singleton(Contracts\RepositoryInterface::class, function($app) { |
|
| 57 | 57 | $path = $app['config']->get('modules.paths.modules'); |
| 58 | 58 | |
| 59 | 59 | if ($app['config']->get('modules.activator') === 'database') { |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | return new Laravel\LaravelFileRepository($app, $path); |
| 64 | 64 | }); |
| 65 | - $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { |
|
| 65 | + $this->app->singleton(Contracts\ActivatorInterface::class, function($app) { |
|
| 66 | 66 | $activator = $app['config']->get('modules.activator'); |
| 67 | - $class = $app['config']->get('modules.activators.' . $activator)['class']; |
|
| 67 | + $class = $app['config']->get('modules.activators.'.$activator)['class']; |
|
| 68 | 68 | |
| 69 | 69 | return new $class($app); |
| 70 | 70 | }); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create(config('modules.activators.database.table'), function (Blueprint $table) { |
|
| 16 | + Schema::create(config('modules.activators.database.table'), function(Blueprint $table) { |
|
| 17 | 17 | $table->bigIncrements('id'); |
| 18 | 18 | $table->string('name'); |
| 19 | 19 | $table->string('alias')->nullable(); |