JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrPKZ_ylaravel-modules/composer.jsonnu[{ "name": "nwidart/laravel-modules", "description": "Laravel Module management", "keywords": [ "modules", "laravel", "nwidart", "module", "rad" ], "license": "MIT", "authors": [ { "name": "Nicolas Widart", "email": "n.widart@gmail.com", "homepage": "https://nicolaswidart.com", "role": "Developer" } ], "require": { "php": ">=8.1", "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "^10.0", "mockery/mockery": "^1.5", "orchestra/testbench": "^8.0", "friendsofphp/php-cs-fixer": "^3.6", "laravel/framework": "^10.0", "spatie/phpunit-snapshot-assertions": "^5.0", "phpstan/phpstan": "^1.4" }, "autoload": { "psr-4": { "Nwidart\\Modules\\": "src" }, "files": [ "src/helpers.php" ] }, "autoload-dev": { "psr-4": { "Nwidart\\Modules\\Tests\\": "tests", "Modules\\Recipe\\": "tests/stubs/valid/Recipe" } }, "extra": { "laravel": { "providers": [ "Nwidart\\Modules\\LaravelModulesServiceProvider" ], "aliases": { "Module": "Nwidart\\Modules\\Facades\\Module" } }, "branch-alias": { "dev-master": "10.0-dev" } }, "scripts": { "update-snapshots": "./vendor/bin/phpunit --no-coverage -d --update-snapshots", "test": "vendor/bin/phpunit", "test-coverage": "vendor/bin/phpunit --coverage-html coverage", "pcf": "vendor/bin/php-cs-fixer fix --verbose" }, "minimum-stability": "dev", "prefer-stable": true } PKZNoo1laravel-modules/src/Traits/ModuleCommandTrait.phpnu[argument('module') ?: app('modules')->getUsedNow(); $module = app('modules')->findOrFail($module); return $module->getStudlyName(); } } PKZ_d3laravel-modules/src/Traits/MigrationLoaderTrait.phpnu[laravel['modules']->getModulePath($module) . $this->getMigrationGeneratorPath(); $files = $this->laravel['files']->glob($path . '/*_*.php'); foreach ($files as $file) { $this->laravel['files']->requireOnce($file); } } /** * Get migration generator path. * * @return string */ protected function getMigrationGeneratorPath() { return $this->laravel['modules']->config('paths.generator.migration'); } } PKZ͢773laravel-modules/src/Traits/CanClearModulesCache.phpnu[forget(config('modules.cache.key')); } } } PKZ Fkk+laravel-modules/src/Migrations/Migrator.phpnu[module = $module; $this->laravel = $application; $this->subpath = $subpath; } /** * Set the database connection to be used * * @param $database * * @return $this */ public function setDatabase($database) { if (is_string($database) && $database) { $this->database = $database; } return $this; } /** * @return Module */ public function getModule() { return $this->module; } /** * Get migration path. * * @return string */ public function getPath() { $config = $this->module->get('migration'); $migrationPath = GenerateConfigReader::read('migration'); $path = (is_array($config) && array_key_exists('path', $config)) ? $config['path'] : $migrationPath->getPath(); return $this->module->getExtraPath($path); } /** * Get migration files. * * @param boolean $reverse * @return array */ public function getMigrations($reverse = false) { if (!empty($this->subpath)) { $files = $this->laravel['files']->glob($this->getPath() . '/' . $this->subpath); } else { $files = $this->laravel['files']->glob($this->getPath() . '/*_*.php'); } // Once we have the array of files in the directory we will just remove the // extension and take the basename of the file which is all we need when // finding the migrations that haven't been run against the databases. if ($files === false) { return []; } $files = array_map(function ($file) { return str_replace('.php', '', basename($file)); }, $files); // Once we have all of the formatted file names we will sort them and since // they all start with a timestamp this should give us the migrations in // the order they were actually created by the application developers. sort($files); if ($reverse) { return array_reverse($files); } return $files; } /** * Rollback migration. * * @return array */ public function rollback() { $migrations = $this->getLast($this->getMigrations(true)); $this->requireFiles($migrations->toArray()); $migrated = []; foreach ($migrations as $migration) { $data = $this->find($migration); if ($data->count()) { $migrated[] = $migration; $this->down($migration); $data->delete(); } } return $migrated; } /** * Reset migration. * * @return array */ public function reset() { $migrations = $this->getMigrations(true); $this->requireFiles($migrations); $migrated = []; foreach ($migrations as $migration) { $data = $this->find($migration); if ($data->count()) { $migrated[] = $migration; $this->down($migration); $data->delete(); } } return $migrated; } /** * Run down schema from the given migration name. * * @param string $migration */ public function down($migration) { $this->resolve($migration)->down(); } /** * Run up schema from the given migration name. * * @param string $migration */ public function up($migration) { $this->resolve($migration)->up(); } /** * Resolve a migration instance from a file. * * @param string $file * * @return object */ public function resolve($file) { $name = implode('_', array_slice(explode('_', $file), 4)); $class = Str::studly($name); if (!class_exists($class) && file_exists($this->getPath() . '/' . $file . '.php')) { return include $this->getPath() . '/' . $file . '.php'; } return new $class(); } /** * Require in all the migration files in a given path. * * @param array $files */ public function requireFiles(array $files) { $path = $this->getPath(); foreach ($files as $file) { $this->laravel['files']->requireOnce($path . '/' . $file . '.php'); } } /** * Get table instance. * * @return \Illuminate\Database\Query\Builder */ public function table() { return $this->laravel['db']->connection($this->database ?: null)->table(config('database.migrations')); } /** * Find migration data from database by given migration name. * * @param string $migration * * @return object */ public function find($migration) { return $this->table()->whereMigration($migration); } /** * Save new migration to database. * * @param string $migration * * @return mixed */ public function log($migration) { return $this->table()->insert([ 'migration' => $migration, 'batch' => $this->getNextBatchNumber(), ]); } /** * Get the next migration batch number. * * @return int */ public function getNextBatchNumber() { return $this->getLastBatchNumber() + 1; } /** * Get the last migration batch number. * * @param array|null $migrations * @return int */ public function getLastBatchNumber($migrations = null) { $table = $this->table(); if (is_array($migrations)) { $table = $table->whereIn('migration', $migrations); } return $table->max('batch'); } /** * Get the last migration batch. * * @param array $migrations * * @return Collection */ public function getLast($migrations) { $query = $this->table() ->where('batch', $this->getLastBatchNumber($migrations)) ->whereIn('migration', $migrations); $result = $query->orderBy('migration', 'desc')->get(); return collect($result)->map(function ($item) { return (array) $item; })->pluck('migration'); } /** * Get the ran migrations. * * @return Collection */ public function getRan() { return $this->table()->pluck('migration'); } } PKZ{||*laravel-modules/src/Routing/Controller.phpnu[cache = $app['cache']; $this->files = $app['files']; $this->config = $app['config']; $this->statusesFile = $this->config('statuses-file'); $this->cacheKey = $this->config('cache-key'); $this->cacheLifetime = $this->config('cache-lifetime'); $this->modulesStatuses = $this->getModulesStatuses(); } /** * Get the path of the file where statuses are stored * * @return string */ public function getStatusesFilePath(): string { return $this->statusesFile; } /** * @inheritDoc */ public function reset(): void { if ($this->files->exists($this->statusesFile)) { $this->files->delete($this->statusesFile); } $this->modulesStatuses = []; $this->flushCache(); } /** * @inheritDoc */ public function enable(Module $module): void { $this->setActiveByName($module->getName(), true); } /** * @inheritDoc */ public function disable(Module $module): void { $this->setActiveByName($module->getName(), false); } /** * @inheritDoc */ public function hasStatus(Module $module, bool $status): bool { if (!isset($this->modulesStatuses[$module->getName()])) { return $status === false; } return $this->modulesStatuses[$module->getName()] === $status; } /** * @inheritDoc */ public function setActive(Module $module, bool $active): void { $this->setActiveByName($module->getName(), $active); } /** * @inheritDoc */ public function setActiveByName(string $name, bool $status): void { $this->modulesStatuses[$name] = $status; $this->writeJson(); $this->flushCache(); } /** * @inheritDoc */ public function delete(Module $module): void { if (!isset($this->modulesStatuses[$module->getName()])) { return; } unset($this->modulesStatuses[$module->getName()]); $this->writeJson(); $this->flushCache(); } /** * Writes the activation statuses in a file, as json */ private function writeJson(): void { $this->files->put($this->statusesFile, json_encode($this->modulesStatuses, JSON_PRETTY_PRINT)); } /** * Reads the json file that contains the activation statuses. * @return array * @throws FileNotFoundException */ private function readJson(): array { if (!$this->files->exists($this->statusesFile)) { return []; } return json_decode($this->files->get($this->statusesFile), true); } /** * Get modules statuses, either from the cache or from * the json statuses file if the cache is disabled. * @return array * @throws FileNotFoundException */ private function getModulesStatuses(): array { if (!$this->config->get('modules.cache.enabled')) { return $this->readJson(); } return $this->cache->store($this->config->get('modules.cache.driver'))->remember($this->cacheKey, $this->cacheLifetime, function () { return $this->readJson(); }); } /** * Reads a config parameter under the 'activators.file' key * * @param string $key * @param $default * @return mixed */ private function config(string $key, $default = null) { return $this->config->get('modules.activators.file.' . $key, $default); } /** * Flushes the modules activation statuses cache */ private function flushCache(): void { $this->cache->store($this->config->get('modules.cache.driver'))->forget($this->cacheKey); } } PKZQm 'laravel-modules/src/Process/Updater.phpnu[module->findOrFail($module); chdir(base_path()); $this->installRequires($module); $this->installDevRequires($module); $this->copyScriptsToMainComposerJson($module); } /** * Check if composer should output anything. * * @return string */ private function isComposerSilenced() { return config('modules.composer.composer-output') === false ? ' --quiet' : ''; } /** * @param Module $module */ private function installRequires(Module $module) { $packages = $module->getComposerAttr('require', []); $concatenatedPackages = ''; foreach ($packages as $name => $version) { $concatenatedPackages .= "\"{$name}:{$version}\" "; } if (!empty($concatenatedPackages)) { $this->run("composer require {$concatenatedPackages}{$this->isComposerSilenced()}"); } } /** * @param Module $module */ private function installDevRequires(Module $module) { $devPackages = $module->getComposerAttr('require-dev', []); $concatenatedPackages = ''; foreach ($devPackages as $name => $version) { $concatenatedPackages .= "\"{$name}:{$version}\" "; } if (!empty($concatenatedPackages)) { $this->run("composer require --dev {$concatenatedPackages}{$this->isComposerSilenced()}"); } } /** * @param Module $module */ private function copyScriptsToMainComposerJson(Module $module) { $scripts = $module->getComposerAttr('scripts', []); $composer = json_decode(file_get_contents(base_path('composer.json')), true); foreach ($scripts as $key => $script) { if (array_key_exists($key, $composer['scripts'])) { $composer['scripts'][$key] = array_unique(array_merge($composer['scripts'][$key], $script)); continue; } $composer['scripts'] = array_merge($composer['scripts'], [$key => $script]); } file_put_contents(base_path('composer.json'), json_encode($composer, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); } } PKZq*k((&laravel-modules/src/Process/Runner.phpnu[module = $module; } /** * Run the given command. * * @param string $command */ public function run($command) { passthru($command); } } PKZJ  )laravel-modules/src/Process/Installer.phpnu[name = $name; $this->version = $version; $this->type = $type; $this->tree = $tree; } /** * Set destination path. * * @param string $path * * @return $this */ public function setPath($path) { $this->path = $path; return $this; } /** * Set the module repository instance. * @param \Nwidart\Modules\Contracts\RepositoryInterface $repository * @return $this */ public function setRepository(RepositoryInterface $repository) { $this->repository = $repository; return $this; } /** * Set console command instance. * * @param \Illuminate\Console\Command $console * * @return $this */ public function setConsole(Command $console) { $this->console = $console; return $this; } /** * Set process timeout. * * @param int $timeout * * @return $this */ public function setTimeout($timeout) { $this->timeout = $timeout; return $this; } /** * Run the installation process. * * @return \Symfony\Component\Process\Process */ public function run() { $process = $this->getProcess(); $process->setTimeout($this->timeout); if ($this->console instanceof Command) { $process->run(function ($type, $line) { $this->console->line($line); }); } return $process; } /** * Get process instance. * * @return \Symfony\Component\Process\Process */ public function getProcess() { if ($this->type) { if ($this->tree) { return $this->installViaSubtree(); } return $this->installViaGit(); } return $this->installViaComposer(); } /** * Get destination path. * * @return string */ public function getDestinationPath() { if ($this->path) { return $this->path; } return $this->repository->getModulePath($this->getModuleName()); } /** * Get git repo url. * * @return string|null */ public function getRepoUrl() { switch ($this->type) { case 'github': return "git@github.com:{$this->name}.git"; case 'github-https': return "https://github.com/{$this->name}.git"; case 'gitlab': return "git@gitlab.com:{$this->name}.git"; break; case 'bitbucket': return "git@bitbucket.org:{$this->name}.git"; default: // Check of type 'scheme://host/path' if (filter_var($this->type, FILTER_VALIDATE_URL)) { return $this->type; } // Check of type 'user@host' if (filter_var($this->type, FILTER_VALIDATE_EMAIL)) { return "{$this->type}:{$this->name}.git"; } return; break; } } /** * Get branch name. * * @return string */ public function getBranch() { return is_null($this->version) ? 'master' : $this->version; } /** * Get module name. * * @return string */ public function getModuleName() { $parts = explode('/', $this->name); return Str::studly(end($parts)); } /** * Get composer package name. * * @return string */ public function getPackageName() { if (is_null($this->version)) { return $this->name . ':dev-master'; } return $this->name . ':' . $this->version; } /** * Install the module via git. * * @return \Symfony\Component\Process\Process */ public function installViaGit() { return Process::fromShellCommandline(sprintf( 'cd %s && git clone %s %s && cd %s && git checkout %s', base_path(), $this->getRepoUrl(), $this->getDestinationPath(), $this->getDestinationPath(), $this->getBranch() )); } /** * Install the module via git subtree. * * @return \Symfony\Component\Process\Process */ public function installViaSubtree() { return Process::fromShellCommandline(sprintf( 'cd %s && git remote add %s %s && git subtree add --prefix=%s --squash %s %s', base_path(), $this->getModuleName(), $this->getRepoUrl(), $this->getDestinationPath(), $this->getModuleName(), $this->getBranch() )); } /** * Install the module via composer. * * @return \Symfony\Component\Process\Process */ public function installViaComposer() { return Process::fromShellCommandline(sprintf( 'cd %s && composer require %s', base_path(), $this->getPackageName() )); } } PKZʻ5laravel-modules/src/Support/Migrations/NameParser.phpnu[ [ 'create', 'make', ], 'delete' => [ 'delete', 'remove', ], 'add' => [ 'add', 'update', 'append', 'insert', ], 'drop' => [ 'destroy', 'drop', ], ]; /** * The constructor. * * @param string $name */ public function __construct($name) { $this->name = $name; $this->data = $this->fetchData(); } /** * Get original migration name. * * @return string */ public function getOriginalName() { return $this->name; } /** * Get schema type or action. * * @return string */ public function getAction() { return head($this->data); } /** * Get the table will be used. * * @return string */ public function getTableName() { $matches = array_reverse($this->getMatches()); return array_shift($matches); } /** * Get matches data from regex. * * @return array */ public function getMatches() { preg_match($this->getPattern(), $this->name, $matches); return $matches; } /** * Get name pattern. * * @return string */ public function getPattern() { switch ($action = $this->getAction()) { case 'add': case 'append': case 'update': case 'insert': return "/{$action}_(.*)_to_(.*)_table/"; break; case 'delete': case 'remove': case 'alter': return "/{$action}_(.*)_from_(.*)_table/"; break; default: return "/{$action}_(.*)_table/"; break; } } /** * Fetch the migration name to an array data. * * @return array */ protected function fetchData() { return explode('_', $this->name); } /** * Get the array data. * * @return array */ public function getData() { return $this->data; } /** * Determine whether the given type is same with the current schema action or type. * * @param $type * * @return bool */ public function is($type) { return $type === $this->getAction(); } /** * Determine whether the current schema action is a adding action. * * @return bool */ public function isAdd() { return in_array($this->getAction(), $this->actions['add']); } /** * Determine whether the current schema action is a deleting action. * * @return bool */ public function isDelete() { return in_array($this->getAction(), $this->actions['delete']); } /** * Determine whether the current schema action is a creating action. * * @return bool */ public function isCreate() { return in_array($this->getAction(), $this->actions['create']); } /** * Determine whether the current schema action is a dropping action. * * @return bool */ public function isDrop() { return in_array($this->getAction(), $this->actions['drop']); } } PKZ}rHQ7laravel-modules/src/Support/Migrations/SchemaParser.phpnu[ 'rememberToken()', 'soft_delete' => 'softDeletes()', ]; /** * The migration schema. * * @var string */ protected $schema; /** * The relationship keys. * * @var array */ protected $relationshipKeys = [ 'belongsTo', ]; /** * Create new instance. * * @param string|null $schema */ public function __construct($schema = null) { $this->schema = $schema; } /** * Parse a string to array of formatted schema. * * @param string $schema * * @return array */ public function parse($schema) { $this->schema = $schema; $parsed = []; foreach ($this->getSchemas() as $schemaArray) { $column = $this->getColumn($schemaArray); $attributes = $this->getAttributes($column, $schemaArray); $parsed[$column] = $attributes; } return $parsed; } /** * Get array of schema. * * @return array */ public function getSchemas() { if (is_null($this->schema)) { return []; } return explode(',', str_replace(' ', '', $this->schema)); } /** * Convert string migration to array. * * @return array */ public function toArray() { return $this->parse($this->schema); } /** * Render the migration to formatted script. * * @return string */ public function render() { $results = ''; foreach ($this->toArray() as $column => $attributes) { $results .= $this->createField($column, $attributes); } return $results; } /** * Render up migration fields. * * @return string */ public function up() { return $this->render(); } /** * Render down migration fields. * * @return string */ public function down() { $results = ''; foreach ($this->toArray() as $column => $attributes) { $attributes = [head($attributes)]; $results .= $this->createField($column, $attributes, 'remove'); } return $results; } /** * Create field. * * @param string $column * @param array $attributes * @param string $type * * @return string */ public function createField($column, $attributes, $type = 'add') { $results = "\t\t\t" . '$table'; foreach ($attributes as $key => $field) { if (in_array($column, $this->relationshipKeys)) { $results .= $this->addRelationColumn($key, $field, $column); } else { $results .= $this->{"{$type}Column"}($key, $field, $column); } } return $results . ';' . PHP_EOL; } /** * Add relation column. * * @param int $key * @param string $field * @param string $column * * @return string */ protected function addRelationColumn($key, $field, $column) { if ($key === 0) { $relatedColumn = Str::snake(class_basename($field)) . '_id'; return "->integer('{$relatedColumn}')->unsigned();" . PHP_EOL . "\t\t\t" . "\$table->foreign('{$relatedColumn}')"; } if ($key === 1) { return "->references('{$field}')"; } if ($key === 2) { return "->on('{$field}')"; } if (Str::contains($field, '(')) { return '->' . $field; } return '->' . $field . '()'; } /** * Format field to script. * * @param int $key * @param string $field * @param string $column * * @return string */ protected function addColumn($key, $field, $column) { if ($this->hasCustomAttribute($column)) { return '->' . $field; } if ($key == 0) { return '->' . $field . "('" . $column . "')"; } if (Str::contains($field, '(')) { return '->' . $field; } return '->' . $field . '()'; } /** * Format field to script. * * @param int $key * @param string $field * @param string $column * * @return string */ protected function removeColumn($key, $field, $column) { if ($this->hasCustomAttribute($column)) { return '->' . $field; } return '->dropColumn(' . "'" . $column . "')"; } /** * Get column name from schema. * * @param string $schema * * @return string */ public function getColumn($schema) { return Arr::get(explode(':', $schema), 0); } /** * Get column attributes. * * @param string $column * @param string $schema * * @return array */ public function getAttributes($column, $schema) { $fields = str_replace($column . ':', '', $schema); return $this->hasCustomAttribute($column) ? $this->getCustomAttribute($column) : explode(':', $fields); } /** * Determine whether the given column is exist in customAttributes array. * * @param string $column * * @return bool */ public function hasCustomAttribute($column) { return array_key_exists($column, $this->customAttributes); } /** * Get custom attributes value. * * @param string $column * * @return array */ public function getCustomAttribute($column) { return (array) $this->customAttributes[$column]; } } PKZ4laravel-modules/src/Support/Config/GeneratorPath.phpnu[path = $config['path']; $this->generate = $config['generate']; $this->namespace = $config['namespace'] ?? $this->convertPathToNamespace($config['path']); return; } $this->path = $config; $this->generate = (bool) $config; $this->namespace = $config; } public function getPath() { return $this->path; } public function generate(): bool { return $this->generate; } public function getNamespace() { return $this->namespace; } private function convertPathToNamespace($path) { return str_replace('/', '\\', $path); } } PKZ(A;laravel-modules/src/Support/Config/GenerateConfigReader.phpnu[path = $path; $this->replaces = $replaces; } /** * Create new self instance. * * @param string $path * @param array $replaces * * @return self */ public static function create($path, array $replaces = []) { return new static($path, $replaces); } /** * Set stub path. * * @param string $path * * @return self */ public function setPath($path) { $this->path = $path; return $this; } /** * Get stub path. * * @return string */ public function getPath() { $path = static::getBasePath() . $this->path; return file_exists($path) ? $path : __DIR__ . '/../Commands/stubs' . $this->path; } /** * Set base path. * * @param string $path */ public static function setBasePath($path) { static::$basePath = $path; } /** * Get base path. * * @return string|null */ public static function getBasePath() { return static::$basePath; } /** * Get stub contents. * * @return mixed|string */ public function getContents() { $contents = file_get_contents($this->getPath()); foreach ($this->replaces as $search => $replace) { $contents = str_replace('$' . strtoupper($search) . '$', $replace, $contents); } return $contents; } /** * Get stub contents. * * @return string */ public function render() { return $this->getContents(); } /** * Save stub to specific path. * * @param string $path * @param string $filename * * @return bool */ public function saveTo($path, $filename) { return file_put_contents($path . '/' . $filename, $this->getContents()); } /** * Set replacements array. * * @param array $replaces * * @return $this */ public function replace(array $replaces = []) { $this->replaces = $replaces; return $this; } /** * Get replacements. * * @return array */ public function getReplaces() { return $this->replaces; } /** * Handle magic method __toString. * * @return string */ public function __toString() { return $this->render(); } } PKZ(nKK,laravel-modules/src/Generators/Generator.phpnu[path = $path; $this->contents = $contents; $this->filesystem = $filesystem ?: new Filesystem(); } /** * Get contents. * * @return mixed */ public function getContents() { return $this->contents; } /** * Set contents. * * @param mixed $contents * * @return $this */ public function setContents($contents) { $this->contents = $contents; return $this; } /** * Get filesystem. * * @return mixed */ public function getFilesystem() { return $this->filesystem; } /** * Set filesystem. * * @param Filesystem $filesystem * * @return $this */ public function setFilesystem(Filesystem $filesystem) { $this->filesystem = $filesystem; return $this; } /** * Get path. * * @return mixed */ public function getPath() { return $this->path; } /** * Set path. * * @param mixed $path * * @return $this */ public function setPath($path) { $this->path = $path; return $this; } public function withFileOverwrite(bool $overwrite): FileGenerator { $this->overwriteFile = $overwrite; return $this; } /** * Generate the file. */ public function generate() { $path = $this->getPath(); if (!$this->filesystem->exists($path)) { return $this->filesystem->put($path, $this->getContents()); } if ($this->overwriteFile === true) { return $this->filesystem->put($path, $this->getContents()); } throw new FileAlreadyExistException('File already exists!'); } } PKZT332laravel-modules/src/Generators/ModuleGenerator.phpnu[name = $name; $this->config = $config; $this->filesystem = $filesystem; $this->console = $console; $this->module = $module; $this->activator = $activator; } /** * Set type. * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Set active flag. * * @param bool $active * * @return $this */ public function setActive(bool $active) { $this->isActive = $active; return $this; } /** * Get the name of module will created. By default in studly case. * * @return string */ public function getName() { return Str::studly($this->name); } /** * Get the laravel config instance. * * @return Config */ public function getConfig() { return $this->config; } /** * Set the laravel config instance. * * @param Config $config * * @return $this */ public function setConfig($config) { $this->config = $config; return $this; } /** * Set the modules activator * * @param ActivatorInterface $activator * * @return $this */ public function setActivator(ActivatorInterface $activator) { $this->activator = $activator; return $this; } /** * Get the laravel filesystem instance. * * @return Filesystem */ public function getFilesystem() { return $this->filesystem; } /** * Set the laravel filesystem instance. * * @param Filesystem $filesystem * * @return $this */ public function setFilesystem($filesystem) { $this->filesystem = $filesystem; return $this; } /** * Get the laravel console instance. * * @return Console */ public function getConsole() { return $this->console; } /** * Set the laravel console instance. * * @param Console $console * * @return $this */ public function setConsole($console) { $this->console = $console; return $this; } /** * @return \Illuminate\Console\View\Components\Factory */ public function getComponent(): \Illuminate\Console\View\Components\Factory { return $this->component; } /** * @param \Illuminate\Console\View\Components\Factory $component */ public function setComponent(\Illuminate\Console\View\Components\Factory $component): self { $this->component = $component; return $this; } /** * Get the module instance. * * @return \Nwidart\Modules\Module */ public function getModule() { return $this->module; } /** * Set the module instance. * * @param mixed $module * * @return $this */ public function setModule($module) { $this->module = $module; return $this; } /** * Get the list of folders will created. * * @return array */ public function getFolders() { return $this->module->config('paths.generator'); } /** * Get the list of files will created. * * @return array */ public function getFiles() { return $this->module->config('stubs.files'); } /** * Set force status. * * @param bool|int $force * * @return $this */ public function setForce($force) { $this->force = $force; return $this; } /** * Generate the module. */ public function generate(): int { $name = $this->getName(); if ($this->module->has($name)) { if ($this->force) { $this->module->delete($name); } else { $this->component->error("Module [{$name}] already exists!"); return E_ERROR; } } $this->component->info("Creating module: [$name]"); $this->generateFolders(); $this->generateModuleJsonFile(); if ($this->type !== 'plain') { $this->generateFiles(); $this->generateResources(); } if ($this->type === 'plain') { $this->cleanModuleJsonFile(); } $this->activator->setActiveByName($name, $this->isActive); $this->console->newLine(1); $this->component->info("Module [{$name}] created successfully."); return 0; } /** * Generate the folders. */ public function generateFolders() { foreach ($this->getFolders() as $key => $folder) { $folder = GenerateConfigReader::read($key); if ($folder->generate() === false) { continue; } $path = $this->module->getModulePath($this->getName()) . '/' . $folder->getPath(); $this->filesystem->makeDirectory($path, 0755, true); if (config('modules.stubs.gitkeep')) { $this->generateGitKeep($path); } } } /** * Generate git keep to the specified path. * * @param string $path */ public function generateGitKeep($path) { $this->filesystem->put($path . '/.gitkeep', ''); } /** * Generate the files. */ public function generateFiles() { foreach ($this->getFiles() as $stub => $file) { $path = $this->module->getModulePath($this->getName()) . $file; $this->component->task("Generating file {$path}",function () use ($stub, $path) { if (!$this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } $this->filesystem->put($path, $this->getStubContents($stub)); }); } } /** * Generate some resources. */ public function generateResources() { if (GenerateConfigReader::read('seeder')->generate() === true) { $this->console->call('module:make-seed', [ 'name' => $this->getName(), 'module' => $this->getName(), '--master' => true, ]); } if (GenerateConfigReader::read('provider')->generate() === true) { $this->console->call('module:make-provider', [ 'name' => $this->getName() . 'ServiceProvider', 'module' => $this->getName(), '--master' => true, ]); $this->console->call('module:route-provider', [ 'module' => $this->getName(), ]); } if (GenerateConfigReader::read('controller')->generate() === true) { $options = $this->type=='api' ? ['--api'=>true] : []; $this->console->call('module:make-controller', [ 'controller' => $this->getName() . 'Controller', 'module' => $this->getName(), ]+$options); } } /** * Get the contents of the specified stub file by given stub name. * * @param $stub * * @return string */ protected function getStubContents($stub) { return (new Stub( '/' . $stub . '.stub', $this->getReplacement($stub) ) )->render(); } /** * get the list for the replacements. */ public function getReplacements() { return $this->module->config('stubs.replacements'); } /** * Get array replacement for the specified stub. * * @param $stub * * @return array */ protected function getReplacement($stub) { $replacements = $this->module->config('stubs.replacements'); if (!isset($replacements[$stub])) { return []; } $keys = $replacements[$stub]; $replaces = []; if ($stub === 'json' || $stub === 'composer') { if (in_array('PROVIDER_NAMESPACE', $keys, true) === false) { $keys[] = 'PROVIDER_NAMESPACE'; } } foreach ($keys as $key) { if (method_exists($this, $method = 'get' . ucfirst(Str::studly(strtolower($key))) . 'Replacement')) { $replaces[$key] = $this->$method(); } else { $replaces[$key] = null; } } return $replaces; } /** * Generate the module.json file */ private function generateModuleJsonFile() { $path = $this->module->getModulePath($this->getName()) . 'module.json'; $this->component->task("Generating file $path",function () use ($path) { if (!$this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } $this->filesystem->put($path, $this->getStubContents('json')); }); } /** * Remove the default service provider that was added in the module.json file * This is needed when a --plain module was created */ private function cleanModuleJsonFile() { $path = $this->module->getModulePath($this->getName()) . 'module.json'; $content = $this->filesystem->get($path); $namespace = $this->getModuleNamespaceReplacement(); $studlyName = $this->getStudlyNameReplacement(); $provider = '"' . $namespace . '\\\\' . $studlyName . '\\\\Providers\\\\' . $studlyName . 'ServiceProvider"'; $content = str_replace($provider, '', $content); $this->filesystem->put($path, $content); } /** * Get the module name in lower case. * * @return string */ protected function getLowerNameReplacement() { return strtolower($this->getName()); } /** * Get the module name in studly case. * * @return string */ protected function getStudlyNameReplacement() { return $this->getName(); } /** * Get replacement for $VENDOR$. * * @return string */ protected function getVendorReplacement() { return $this->module->config('composer.vendor'); } /** * Get replacement for $MODULE_NAMESPACE$. * * @return string */ protected function getModuleNamespaceReplacement() { return str_replace('\\', '\\\\', $this->module->config('namespace')); } /** * Get replacement for $AUTHOR_NAME$. * * @return string */ protected function getAuthorNameReplacement() { return $this->module->config('composer.author.name'); } /** * Get replacement for $AUTHOR_EMAIL$. * * @return string */ protected function getAuthorEmailReplacement() { return $this->module->config('composer.author.email'); } protected function getProviderNamespaceReplacement(): string { return str_replace('\\', '\\\\', GenerateConfigReader::read('provider')->getNamespace()); } } PKZGr " "laravel-modules/src/Module.phpnu[name = $name; $this->path = $path; $this->cache = $app['cache']; $this->files = $app['files']; $this->translator = $app['translator']; $this->activator = $app[ActivatorInterface::class]; $this->app = $app; } /** * Get name. * * @return string */ public function getName(): string { return $this->name; } /** * Get name in lower case. * * @return string */ public function getLowerName(): string { return strtolower($this->name); } /** * Get name in studly case. * * @return string */ public function getStudlyName(): string { return Str::studly($this->name); } /** * Get name in snake case. * * @return string */ public function getSnakeName(): string { return Str::snake($this->name); } /** * Get description. * * @return string */ public function getDescription(): string { return $this->get('description'); } /** * Get priority. * * @return string */ public function getPriority(): string { return $this->get('priority'); } /** * Get path. * * @return string */ public function getPath(): string { return $this->path; } /** * Set path. * * @param string $path * * @return $this */ public function setPath($path): Module { $this->path = $path; return $this; } /** * Bootstrap the application events. */ public function boot(): void { if (config('modules.register.translations', true) === true) { $this->registerTranslation(); } if ($this->isLoadFilesOnBoot()) { $this->registerFiles(); } $this->fireEvent('boot'); } /** * Register module's translation. * * @return void */ protected function registerTranslation(): void { $lowerName = $this->getLowerName(); $langPath = $this->getPath() . '/Resources/lang'; if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $lowerName); } } /** * Get json contents from the cache, setting as needed. * * @param string $file * * @return Json */ public function json($file = null): Json { if ($file === null) { $file = 'module.json'; } return Arr::get($this->moduleJson, $file, function () use ($file) { return $this->moduleJson[$file] = new Json($this->getPath() . '/' . $file, $this->files); }); } /** * Get a specific data from json file by given the key. * * @param string $key * @param null $default * * @return mixed */ public function get(string $key, $default = null) { return $this->json()->get($key, $default); } /** * Get a specific data from composer.json file by given the key. * * @param $key * @param null $default * * @return mixed */ public function getComposerAttr($key, $default = null) { return $this->json('composer.json')->get($key, $default); } /** * Register the module. */ public function register(): void { $this->registerAliases(); $this->registerProviders(); if ($this->isLoadFilesOnBoot() === false) { $this->registerFiles(); } $this->fireEvent('register'); } /** * Register the module event. * * @param string $event */ protected function fireEvent($event): void { $this->app['events']->dispatch(sprintf('modules.%s.' . $event, $this->getLowerName()), [$this]); } /** * Register the aliases from this module. */ abstract public function registerAliases(): void; /** * Register the service providers from this module. */ abstract public function registerProviders(): void; /** * Get the path to the cached *_module.php file. * * @return string */ abstract public function getCachedServicesPath(): string; /** * Register the files from this module. */ protected function registerFiles(): void { foreach ($this->get('files', []) as $file) { include $this->path . '/' . $file; } } /** * Handle call __toString. * * @return string */ public function __toString() { return $this->getStudlyName(); } /** * Determine whether the given status same with the current module status. * * @param bool $status * * @return bool */ public function isStatus(bool $status): bool { return $this->activator->hasStatus($this, $status); } /** * Determine whether the current module activated. * * @return bool */ public function isEnabled(): bool { return $this->activator->hasStatus($this, true); } /** * Determine whether the current module not disabled. * * @return bool */ public function isDisabled(): bool { return !$this->isEnabled(); } /** * Set active state for current module. * * @param bool $active * * @return void */ public function setActive(bool $active): void { $this->activator->setActive($this, $active); } /** * Disable the current module. */ public function disable(): void { $this->fireEvent('disabling'); $this->activator->disable($this); $this->flushCache(); $this->fireEvent('disabled'); } /** * Enable the current module. */ public function enable(): void { $this->fireEvent('enabling'); $this->activator->enable($this); $this->flushCache(); $this->fireEvent('enabled'); } /** * Delete the current module. * * @return bool */ public function delete(): bool { $this->activator->delete($this); return $this->json()->getFilesystem()->deleteDirectory($this->getPath()); } /** * Get extra path. * * @param string $path * * @return string */ public function getExtraPath(string $path): string { return $this->getPath() . '/' . $path; } /** * Check if can load files of module on boot method. * * @return bool */ protected function isLoadFilesOnBoot(): bool { return config('modules.register.files', 'register') === 'boot' && // force register method if option == boot && app is AsgardCms !class_exists('\Modules\Core\Foundation\AsgardCms'); } private function flushCache(): void { if (config('modules.cache.enabled')) { $this->cache->store(config('modules.cache.driver'))->flush(); } } /** * Register a translation file namespace. * * @param string $path * @param string $namespace * @return void */ private function loadTranslationsFrom(string $path, string $namespace): void { $this->translator->addNamespace($namespace, $path); } } PKZlaravel-modules/src/Json.phpnu[path = (string) $path; $this->filesystem = $filesystem ?: new Filesystem(); $this->attributes = Collection::make($this->getAttributes()); } /** * Get filesystem. * * @return Filesystem */ public function getFilesystem() { return $this->filesystem; } /** * Set filesystem. * * @param Filesystem $filesystem * * @return $this */ public function setFilesystem(Filesystem $filesystem) { $this->filesystem = $filesystem; return $this; } /** * Get path. * * @return string */ public function getPath() { return $this->path; } /** * Set path. * * @param mixed $path * * @return $this */ public function setPath($path) { $this->path = (string) $path; return $this; } /** * Make new instance. * * @param string $path * @param \Illuminate\Filesystem\Filesystem $filesystem * * @return static */ public static function make($path, Filesystem $filesystem = null) { return new static($path, $filesystem); } /** * Get file content. * * @return string */ public function getContents() { return $this->filesystem->get($this->getPath()); } /** * Decode contents as array. * * @return array * @throws InvalidJsonException */ public function decodeContents() { $attributes = json_decode($this->getContents(), 1); // any JSON parsing errors should throw an exception if (json_last_error() > 0) { throw new InvalidJsonException('Error processing file: ' . $this->getPath() . '. Error: ' . json_last_error_msg()); } return $attributes; } /** * Get file contents as array, either from the cache or from * the json content file if the cache is disabled. * @return array * @throws \Exception */ public function getAttributes() { if (config('modules.cache.enabled') === false) { return $this->decodeContents(); } return app('cache')->store(config('modules.cache.driver'))->remember($this->getPath(), config('modules.cache.lifetime'), function () { return $this->decodeContents(); }); } /** * Convert the given array data to pretty json. * * @param array $data * * @return string */ public function toJsonPretty(array $data = null) { return json_encode($data ?: $this->attributes, JSON_PRETTY_PRINT); } /** * Update json contents from array data. * * @param array $data * * @return bool */ public function update(array $data) { $this->attributes = new Collection(array_merge($this->attributes->toArray(), $data)); return $this->save(); } /** * Set a specific key & value. * * @param string $key * @param mixed $value * * @return $this */ public function set($key, $value) { $this->attributes->offsetSet($key, $value); return $this; } /** * Save the current attributes array to the file storage. * * @return bool */ public function save() { return $this->filesystem->put($this->getPath(), $this->toJsonPretty()); } /** * Handle magic method __get. * * @param string $key * * @return mixed */ public function __get($key) { return $this->get($key); } /** * Get the specified attribute from json file. * * @param $key * @param null $default * * @return mixed */ public function get($key, $default = null) { return $this->attributes->get($key, $default); } /** * Handle call to __call method. * * @param string $method * @param array $arguments * * @return mixed */ public function __call($method, $arguments = []) { if (method_exists($this, $method)) { return call_user_func_array([$this, $method], $arguments); } return call_user_func_array([$this->attributes, $method], $arguments); } /** * Handle call to __toString method. * * @return string */ public function __toString() { return $this->getContents(); } } PKZ5gD 4laravel-modules/src/Commands/MigrateResetCommand.phpnu[module = $this->laravel['modules']; $name = $this->argument('module'); if (!empty($name)) { $this->reset($name); return 0; } foreach ($this->module->getOrdered($this->option('direction')) as $module) { $this->line('Running for module: ' . $module->getName() . ''); $this->reset($module); } return 0; } /** * Rollback migration from the specified module. * * @param $module */ public function reset($module) { if (is_string($module)) { $module = $this->module->findOrFail($module); } $migrator = new Migrator($module, $this->getLaravel()); $database = $this->option('database'); if (!empty($database)) { $migrator->setDatabase($database); } $migrated = $migrator->reset(); if (count($migrated)) { foreach ($migrated as $migration) { $this->line("Rollback: {$migration}"); } return; } $this->comment('Nothing to rollback.'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'desc'], ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], ]; } } PKZII0laravel-modules/src/Commands/MailMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.emails.namespace') ?: $module->config('paths.generator.emails.path', 'Emails'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the mailable.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get template contents. * * @return string */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/mail.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * Get the destination file path. * * @return string */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $mailPath = GenerateConfigReader::read('emails'); return $path . $mailPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } } PKZnA 2laravel-modules/src/Commands/ModuleMakeCommand.phpnu[argument('name'); $success = true; foreach ($names as $name) { $code = with(new ModuleGenerator($name)) ->setFilesystem($this->laravel['files']) ->setModule($this->laravel['modules']) ->setConfig($this->laravel['config']) ->setActivator($this->laravel[ActivatorInterface::class]) ->setConsole($this) ->setComponent($this->components) ->setForce($this->option('force')) ->setType($this->getModuleType()) ->setActive(!$this->option('disabled')) ->generate(); if ($code === E_ERROR) { $success = false; } } return $success ? 0 : E_ERROR; } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::IS_ARRAY, 'The names of modules will be created.'], ]; } protected function getOptions() { return [ ['plain', 'p', InputOption::VALUE_NONE, 'Generate a plain module (without some resources).'], ['api', null, InputOption::VALUE_NONE, 'Generate an api module.'], ['web', null, InputOption::VALUE_NONE, 'Generate a web module.'], ['disabled', 'd', InputOption::VALUE_NONE, 'Do not enable the module at creation.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when the module already exists.'], ]; } /** * Get module type . * * @return string */ private function getModuleType() { $isPlain = $this->option('plain'); $isApi = $this->option('api'); if ($isPlain && $isApi) { return 'web'; } if ($isPlain) { return 'plain'; } elseif ($isApi) { return 'api'; } else { return 'web'; } } } PKZGGff:laravel-modules/src/Commands/PublishTranslationCommand.phpnu[components->info('Publishing module translations...'); if ($name = $this->argument('module')) { $this->publish($name); return 0; } $this->publishAll(); return 0; } /** * Publish assets from all modules. */ public function publishAll() { foreach ($this->laravel['modules']->allEnabled() as $module) { $this->publish($module); } } /** * Publish assets from the specified module. * * @param string $name */ public function publish($name) { if ($name instanceof Module) { $module = $name; } else { $module = $this->laravel['modules']->findOrFail($name); } with(new LangPublisher($module)) ->setRepository($this->laravel['modules']) ->setConsole($this) ->publish(); $this->line("Published: {$module->getStudlyName()}"); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } } PKZQ-laravel-modules/src/Commands/SetupCommand.phpnu[generateModulesFolder(); return $this->generateAssetsFolder() | $code; } /** * Generate the modules folder. */ public function generateModulesFolder() { return $this->generateDirectory( $this->laravel['modules']->config('paths.modules'), 'Modules directory created successfully', 'Modules directory already exist' ); } /** * Generate the assets folder. */ public function generateAssetsFolder() { return $this->generateDirectory( $this->laravel['modules']->config('paths.assets'), 'Assets directory created successfully', 'Assets directory already exist' ); } /** * Generate the specified directory by given $dir. * * @param $dir * @param $success * @param $error * @return int */ protected function generateDirectory($dir, $success, $error): int { if (!$this->laravel['files']->isDirectory($dir)) { $this->laravel['files']->makeDirectory($dir, 0755, true, true); $this->components->info($success); return 0; } $this->components->error($error); return E_ERROR; } } PKZ/E E /laravel-modules/src/Commands/JobMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.jobs.namespace') ?: $module->config('paths.generator.jobs.path', 'Jobs'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the job.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['sync', null, InputOption::VALUE_NONE, 'Indicates that job should be synchronous.'], ]; } /** * Get template contents. * * @return string */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * Get the destination file path. * * @return string */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $jobPath = GenerateConfigReader::read('jobs'); return $path . $jobPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } /** * @return string */ protected function getStubName(): string { if ($this->option('sync')) { return '/job.stub'; } return '/job-queued.stub'; } } PKZ0% 1laravel-modules/src/Commands/GeneratorCommand.phpnu[getDestinationFilePath()); if (!$this->laravel['files']->isDirectory($dir = dirname($path))) { $this->laravel['files']->makeDirectory($dir, 0777, true); } $contents = $this->getTemplateContents(); try { $this->components->task("Generating file {$path}",function () use ($path,$contents) { $overwriteFile = $this->hasOption('force') ? $this->option('force') : false; (new FileGenerator($path, $contents))->withFileOverwrite($overwriteFile)->generate(); }); } catch (FileAlreadyExistException $e) { $this->components->error("File : {$path} already exists."); return E_ERROR; } return 0; } /** * Get class name. * * @return string */ public function getClass() { return class_basename($this->argument($this->argumentName)); } /** * Get default namespace. * * @return string */ public function getDefaultNamespace(): string { return ''; } /** * Get class namespace. * * @param \Nwidart\Modules\Module $module * * @return string */ public function getClassNamespace($module) { $extra = str_replace($this->getClass(), '', $this->argument($this->argumentName)); $extra = str_replace('/', '\\', $extra); $namespace = $this->laravel['modules']->config('namespace'); $namespace .= '\\' . $module->getStudlyName(); $namespace .= '\\' . $this->getDefaultNamespace(); $namespace .= '\\' . $extra; $namespace = str_replace('/', '\\', $namespace); return trim($namespace, '\\'); } } PKZ23__2laravel-modules/src/Commands/PolicyMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.policies.namespace') ?: $module->config('paths.generator.policies.path', 'Policies'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the policy class.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/policy.plain.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $policyPath = GenerateConfigReader::read('policies'); return $path . $policyPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } } PKZ :laravel-modules/src/Commands/ComponentClassMakeCommand.phpnu[writeComponentViewTemplate(); return 0; } /** * Write the view template for the component. * * @return void */ protected function writeComponentViewTemplate() { $this->call('module:make-component-view', ['name' => $this->argument('name') , 'module' => $this->argument('module')]); } public function getDefaultNamespace(): string { $module = $this->laravel['modules']; return $module->config('paths.generator.component-class.namespace') ?: $module->config('paths.generator.component-class.path', 'View/Component'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the component.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/component-class.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), 'LOWER_NAME' => $module->getLowerName(), 'COMPONENT_NAME' => 'components.' . Str::lower($this->argument('name')), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $factoryPath = GenerateConfigReader::read('component-class'); return $path . $factoryPath->getPath() . '/' . $this->getFileName(); } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')) . '.php'; } } PKZϑ 6laravel-modules/src/Commands/MigrateRefreshCommand.phpnu[argument('module'); if ($module && !$this->getModuleName()) { $this->error("Module [$module] does not exists."); return E_ERROR; } $this->call('module:migrate-reset', [ 'module' => $this->getModuleName(), '--database' => $this->option('database'), '--force' => $this->option('force'), ]); $this->call('module:migrate', [ 'module' => $this->getModuleName(), '--database' => $this->option('database'), '--force' => $this->option('force'), ]); if ($this->option('seed')) { $this->call('module:seed', [ 'module' => $this->getModuleName(), ]); } return 0; } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], ]; } public function getModuleName() { $module = $this->argument('module'); if (!$module) { return null; } $module = app('modules')->find($module); return $module ? $module->getStudlyName() : null; } } PKZ1GG0laravel-modules/src/Commands/RuleMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.rules.namespace') ?: $module->config('paths.generator.rules.path', 'Rules'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the rule class.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/rule.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getFileName(), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $rulePath = GenerateConfigReader::read('rules'); return $path . $rulePath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } } PKZЖ9 4laravel-modules/src/Commands/ObserverMakeCommand.phpnu[laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/observer.stub', [ 'NAMESPACE' => $this->getClassNamespace($module) . '\Observers', 'NAME' => $this->getModelName(), 'MODEL_NAMESPACE' => $this->getModelNamespace(), 'NAME_VARIABLE' => $this->getModelVariable(), ]))->render(); } /** * Get model namespace. * * @return string */ public function getModelNamespace(): string { $path = $this->laravel['modules']->config('paths.generator.model.path', 'Entities'); $path = str_replace('/', '\\', $path); return $this->laravel['modules']->config('namespace') . '\\' . $this->laravel['modules']->findOrFail($this->getModuleName()) . '\\' . $path; } /** * @return mixed|string */ private function getModelName() { return Str::studly($this->argument('name')); } /** * @return mixed|string */ private function getModelVariable() : string { return '$'.Str::lower($this->argument('name')); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $observerPath = GenerateConfigReader::read('observer'); return $path . $observerPath->getPath() . '/' . $this->getFileName(); } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')) . 'Observer.php'; } public function handle(): int { $this->components->info('Creating observer...'); parent::handle(); return 0; } } PKZiZZ6laravel-modules/src/Commands/ControllerMakeCommand.phpnu[laravel['modules']->getModulePath($this->getModuleName()); $controllerPath = GenerateConfigReader::read('controller'); return $path . $controllerPath->getPath() . '/' . $this->getControllerName() . '.php'; } /** * @return string */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ 'MODULENAME' => $module->getStudlyName(), 'CONTROLLERNAME' => $this->getControllerName(), 'NAMESPACE' => $module->getStudlyName(), 'CLASS_NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getControllerNameWithoutNamespace(), 'LOWER_NAME' => $module->getLowerName(), 'MODULE' => $this->getModuleName(), 'NAME' => $this->getModuleName(), 'STUDLY_NAME' => $module->getStudlyName(), 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), ]))->render(); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['controller', InputArgument::REQUIRED, 'The name of the controller class.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * @return array */ protected function getOptions() { return [ ['plain', 'p', InputOption::VALUE_NONE, 'Generate a plain controller', null], ['api', null, InputOption::VALUE_NONE, 'Exclude the create and edit methods from the controller.'], ]; } /** * @return array|string */ protected function getControllerName() { $controller = Str::studly($this->argument('controller')); if (Str::contains(strtolower($controller), 'controller') === false) { $controller .= 'Controller'; } return $controller; } /** * @return array|string */ private function getControllerNameWithoutNamespace() { return class_basename($this->getControllerName()); } public function getDefaultNamespace(): string { $module = $this->laravel['modules']; return $module->config('paths.generator.controller.namespace') ?: $module->config('paths.generator.controller.path', 'Http/Controllers'); } /** * Get the stub file name based on the options * @return string */ protected function getStubName() { if ($this->option('plain') === true) { $stub = '/controller-plain.stub'; } elseif ($this->option('api') === true) { $stub = '/controller-api.stub'; } else { $stub = '/controller.stub'; } return $stub; } } PKZM+x;Q Q 0laravel-modules/src/Commands/TestMakeCommand.phpnu[laravel['modules']; if ($this->option('feature')) { return $module->config('paths.generator.test-feature.namespace') ?: $module->config('paths.generator.test-feature.path', 'Tests/Feature'); } return $module->config('paths.generator.test.namespace') ?: $module->config('paths.generator.test.path', 'Tests/Unit'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the form request class.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['feature', false, InputOption::VALUE_NONE, 'Create a feature test.'], ]; } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); $stub = '/unit-test.stub'; if ($this->option('feature')) { $stub = '/feature-test.stub'; } return (new Stub($stub, [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); if ($this->option('feature')) { $testPath = GenerateConfigReader::read('test-feature'); } else { $testPath = GenerateConfigReader::read('test'); } return $path . $testPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } } PKZ\[v5laravel-modules/src/Commands/MigrationMakeCommand.phpnu[option('fields')); } /** * @throws \InvalidArgumentException * * @return mixed */ protected function getTemplateContents() { $parser = new NameParser($this->argument('name')); if ($parser->isCreate()) { return Stub::create('/migration/create.stub', [ 'class' => $this->getClass(), 'table' => $parser->getTableName(), 'fields' => $this->getSchemaParser()->render(), ]); } elseif ($parser->isAdd()) { return Stub::create('/migration/add.stub', [ 'class' => $this->getClass(), 'table' => $parser->getTableName(), 'fields_up' => $this->getSchemaParser()->up(), 'fields_down' => $this->getSchemaParser()->down(), ]); } elseif ($parser->isDelete()) { return Stub::create('/migration/delete.stub', [ 'class' => $this->getClass(), 'table' => $parser->getTableName(), 'fields_down' => $this->getSchemaParser()->up(), 'fields_up' => $this->getSchemaParser()->down(), ]); } elseif ($parser->isDrop()) { return Stub::create('/migration/drop.stub', [ 'class' => $this->getClass(), 'table' => $parser->getTableName(), 'fields' => $this->getSchemaParser()->render(), ]); } return Stub::create('/migration/plain.stub', [ 'class' => $this->getClass(), ]); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $generatorPath = GenerateConfigReader::read('migration'); return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return date('Y_m_d_His_') . $this->getSchemaName(); } /** * @return array|string */ private function getSchemaName() { return $this->argument('name'); } /** * @return string */ private function getClassName() { return Str::studly($this->argument('name')); } public function getClass() { return $this->getClassName(); } /** * Run the command. */ public function handle(): int { $this->components->info('Creating migration...'); if (parent::handle() === E_ERROR) { return E_ERROR; } if (app()->environment() === 'testing') { return 0; } return 0; } } PKZ 8laravel-modules/src/Commands/PublishMigrationCommand.phpnu[components->info('publishing module migrations...'); if ($name = $this->argument('module')) { $module = $this->laravel['modules']->findOrFail($name); $this->publish($module); return 0; } foreach ($this->laravel['modules']->allEnabled() as $module) { $this->publish($module); } return 0; } /** * Publish migration for the specified module. * * @param \Nwidart\Modules\Module $module */ public function publish($module) { with(new MigrationPublisher(new Migrator($module, $this->getLaravel()))) ->setRepository($this->laravel['modules']) ->setConsole($this) ->publish(); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module being used.'], ]; } } PKZ⢿4laravel-modules/src/Commands/ModuleDeleteCommand.phpnu[laravel['modules']->delete($this->argument('module')); $this->components->info("Module {$this->argument('module')} has been deleted."); return 0; } protected function getArguments() { return [ ['module', InputArgument::REQUIRED, 'The name of module to delete.'], ]; } } PKZ}ll3laravel-modules/src/Commands/RequestMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.request.namespace') ?: $module->config('paths.generator.request.path', 'Http/Requests'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the form request class.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/request.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $requestPath = GenerateConfigReader::read('request'); return $path . $requestPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } } PKZђ/laravel-modules/src/Commands/InstallCommand.phpnu[argument('name'))) { return $this->installFromFile(); } $this->install( $this->argument('name'), $this->argument('version'), $this->option('type'), $this->option('tree') ); return 0; } /** * Install modules from modules.json file. */ protected function installFromFile(): int { if (!file_exists($path = base_path('modules.json'))) { $this->error("File 'modules.json' does not exist in your project root."); return E_ERROR; } $modules = Json::make($path); $dependencies = $modules->get('require', []); foreach ($dependencies as $module) { $module = collect($module); $this->install( $module->get('name'), $module->get('version'), $module->get('type') ); } return 0; } /** * Install the specified module. * * @param string $name * @param string $version * @param string $type * @param bool $tree */ protected function install($name, $version = 'dev-master', $type = 'composer', $tree = false) { $installer = new Installer( $name, $version, $type ?: $this->option('type'), $tree ?: $this->option('tree') ); $installer->setRepository($this->laravel['modules']); $installer->setConsole($this); if ($timeout = $this->option('timeout')) { $installer->setTimeout($timeout); } if ($path = $this->option('path')) { $installer->setPath($path); } $installer->run(); if (!$this->option('no-update')) { $this->call('module:update', [ 'module' => $installer->getModuleName(), ]); } } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::OPTIONAL, 'The name of module will be installed.'], ['version', InputArgument::OPTIONAL, 'The version of module will be installed.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['timeout', null, InputOption::VALUE_OPTIONAL, 'The process timeout.', null], ['path', null, InputOption::VALUE_OPTIONAL, 'The installation path.', null], ['type', null, InputOption::VALUE_OPTIONAL, 'The type of installation.', null], ['tree', null, InputOption::VALUE_NONE, 'Install the module as a git subtree', null], ['no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.', null], ]; } } PKZn?}}+laravel-modules/src/Commands/UseCommand.phpnu[argument('module')); if (!$this->laravel['modules']->has($module)) { $this->error("Module [{$module}] does not exists."); return E_ERROR; } $this->laravel['modules']->setUsed($module); $this->info("Module [{$module}] used successfully."); return 0; } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::REQUIRED, 'The name of module will be used.'], ]; } } PKZ%Y[n n 3laravel-modules/src/Commands/CommandMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.command.namespace') ?: $module->config('paths.generator.command.path', 'Console'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the command.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null], ]; } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/command.stub', [ 'COMMAND_NAME' => $this->getCommandName(), 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * @return string */ private function getCommandName() { return $this->option('command') ?: 'command:name'; } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $commandPath = GenerateConfigReader::read('command'); return $path . $commandPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } } PKZ. . 6laravel-modules/src/Commands/MiddlewareMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.filter.namespace') ?: $module->config('paths.generator.filter.path', 'Http/Middleware'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the command.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/middleware.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $middlewarePath = GenerateConfigReader::read('filter'); return $path . $middlewarePath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } /** * Run the command. */ public function handle(): int { $this->components->info('Creating middleware...'); parent::handle(); return 0; } } PKZU+ + 4laravel-modules/src/Commands/ProviderMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.provider.namespace') ?: $module->config('paths.generator.provider.path', 'Providers'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The service provider name.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['master', null, InputOption::VALUE_NONE, 'Indicates the master service provider', null], ]; } /** * @return mixed */ protected function getTemplateContents() { $stub = $this->option('master') ? 'scaffold/provider' : 'provider'; /** @var Module $module */ $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/' . $stub . '.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), 'LOWER_NAME' => $module->getLowerName(), 'MODULE' => $this->getModuleName(), 'NAME' => $this->getFileName(), 'STUDLY_NAME' => $module->getStudlyName(), 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), 'PATH_VIEWS' => GenerateConfigReader::read('views')->getPath(), 'PATH_LANG' => GenerateConfigReader::read('lang')->getPath(), 'PATH_CONFIG' => GenerateConfigReader::read('config')->getPath(), 'MIGRATIONS_PATH' => GenerateConfigReader::read('migration')->getPath(), 'FACTORIES_PATH' => GenerateConfigReader::read('factory')->getPath(), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $generatorPath = GenerateConfigReader::read('provider'); return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } } PKZfP P 9laravel-modules/src/Commands/RouteProviderMakeCommand.phpnu[laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/route-provider.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getFileName(), 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), 'MODULE' => $this->getModuleName(), 'CONTROLLER_NAMESPACE' => $this->getControllerNameSpace(), 'WEB_ROUTES_PATH' => $this->getWebRoutesPath(), 'API_ROUTES_PATH' => $this->getApiRoutesPath(), 'LOWER_NAME' => $module->getLowerName(), ]))->render(); } /** * @return string */ private function getFileName() { return 'RouteServiceProvider'; } /** * Get the destination file path. * * @return string */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $generatorPath = GenerateConfigReader::read('provider'); return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return mixed */ protected function getWebRoutesPath() { return '/' . $this->laravel['modules']->config('stubs.files.routes/web', 'Routes/web.php'); } /** * @return mixed */ protected function getApiRoutesPath() { return '/' . $this->laravel['modules']->config('stubs.files.routes/api', 'Routes/api.php'); } public function getDefaultNamespace(): string { $module = $this->laravel['modules']; return $module->config('paths.generator.provider.namespace') ?: $module->config('paths.generator.provider.path', 'Providers'); } /** * @return string */ private function getControllerNameSpace(): string { $module = $this->laravel['modules']; return str_replace('/', '\\', $module->config('paths.generator.controller.namespace') ?: $module->config('paths.generator.controller.path', 'Controller')); } } PKZ*JkLL1laravel-modules/src/Commands/ModelShowCommand.phpnu[module = $this->laravel['modules']; $name = $this->argument('module'); if ($name) { $module = $this->module->findOrFail($name); $this->migrateStatus($module); return 0; } foreach ($this->module->getOrdered($this->option('direction')) as $module) { $this->line('Running for module: ' . $module->getName() . ''); $this->migrateStatus($module); } return 0; } /** * Run the migration from the specified module. * * @param Module $module */ protected function migrateStatus(Module $module) { $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath()); $this->call('migrate:status', [ '--path' => $path, '--database' => $this->option('database'), ]); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ]; } } PKZxx9laravel-modules/src/Commands/LaravelModulesV6Migrator.phpnu[laravel['modules']; $modules = $modules->all(); /** @var Module $module */ foreach ($modules as $module) { if ($module->json()->get('active') === 1) { $module->enable(); $moduleStatuses[] = [$module->getName(), 'Enabled']; } if ($module->json()->get('active') === 0) { $module->disable(); $moduleStatuses[] = [$module->getName(), 'Disabled']; } } $this->info('All modules have been migrated.'); $this->table(['Module name', 'Status'], $moduleStatuses); return 0; } } PKZ:\ S S 4laravel-modules/src/Commands/ResourceMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.resource.namespace') ?: $module->config('paths.generator.resource.path', 'Transformers'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the resource class.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } protected function getOptions() { return [ ['collection', 'c', InputOption::VALUE_NONE, 'Create a resource collection.'], ]; } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $resourcePath = GenerateConfigReader::read('resource'); return $path . $resourcePath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } /** * Determine if the command is generating a resource collection. * * @return bool */ protected function collection(): bool { return $this->option('collection') || Str::endsWith($this->argument('name'), 'Collection'); } /** * @return string */ protected function getStubName(): string { if ($this->collection()) { return '/resource-collection.stub'; } return '/resource.stub'; } } PKZ$9laravel-modules/src/Commands/ComponentViewMakeCommand.phpnu[ Inspiring::quote()]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $factoryPath = GenerateConfigReader::read('component-view'); return $path . $factoryPath->getPath() . '/' . $this->getFileName(); } /** * @return string */ private function getFileName() { return Str::lower($this->argument('name')) . '.blade.php'; } } PKZAN1laravel-modules/src/Commands/ModelMakeCommand.phpnu[handleOptionalMigrationOption(); $this->handleOptionalControllerOption(); $this->handleOptionalSeedOption(); $this->handleOptionalRequestOption(); return 0; } /** * Create a proper migration name: * ProductDetail: product_details * Product: products * @return string */ private function createMigrationName() { $pieces = preg_split('/(?=[A-Z])/', $this->argument('model'), -1, PREG_SPLIT_NO_EMPTY); $string = ''; foreach ($pieces as $i => $piece) { if ($i+1 < count($pieces)) { $string .= strtolower($piece) . '_'; } else { $string .= Str::plural(strtolower($piece)); } } return $string; } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['model', InputArgument::REQUIRED, 'The name of model will be created.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['fillable', null, InputOption::VALUE_OPTIONAL, 'The fillable attributes.', null], ['migration', 'm', InputOption::VALUE_NONE, 'Flag to create associated migrations', null], ['controller', 'c', InputOption::VALUE_NONE, 'Flag to create associated controllers', null], ['seed', 's', InputOption::VALUE_NONE, 'Create a new seeder for the model', null], ['request', 'r', InputOption::VALUE_NONE, 'Create a new request for the model', null] ]; } /** * Create the migration file with the given model if migration flag was used */ private function handleOptionalMigrationOption() { if ($this->option('migration') === true) { $migrationName = 'create_' . $this->createMigrationName() . '_table'; $this->call('module:make-migration', ['name' => $migrationName, 'module' => $this->argument('module')]); } } /** * Create the controller file for the given model if controller flag was used */ private function handleOptionalControllerOption() { if ($this->option('controller') === true) { $controllerName = "{$this->getModelName()}Controller"; $this->call('module:make-controller', array_filter([ 'controller' => $controllerName, 'module' => $this->argument('module'), ])); } } /** * Create a seeder file for the model. * * @return void */ protected function handleOptionalSeedOption() { if ($this->option('seed') === true) { $seedName = "{$this->getModelName()}Seeder"; $this->call('module:make-seed', array_filter([ 'name' => $seedName, 'module' => $this->argument('module') ])); } } /** * Create a request file for the model. * * @return void */ protected function handleOptionalRequestOption() { if ($this->option('request') === true) { $requestName = "{$this->getModelName()}Request"; $this->call('module:make-request', array_filter([ 'name' => $requestName, 'module' => $this->argument('module') ])); } } /** * @return mixed */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/model.stub', [ 'NAME' => $this->getModelName(), 'FILLABLE' => $this->getFillable(), 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), 'LOWER_NAME' => $module->getLowerName(), 'MODULE' => $this->getModuleName(), 'STUDLY_NAME' => $module->getStudlyName(), 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $modelPath = GenerateConfigReader::read('model'); return $path . $modelPath->getPath() . '/' . $this->getModelName() . '.php'; } /** * @return mixed|string */ private function getModelName() { return Str::studly($this->argument('model')); } /** * @return string */ private function getFillable() { $fillable = $this->option('fillable'); if (!is_null($fillable)) { $arrays = explode(',', $fillable); return json_encode($arrays); } return '[]'; } /** * Get default namespace. * * @return string */ public function getDefaultNamespace(): string { $module = $this->laravel['modules']; return $module->config('paths.generator.model.namespace') ?: $module->config('paths.generator.model.path', 'Entities'); } } PKZ q,laravel-modules/src/Commands/SeedCommand.phpnu[argument('module')) { $name = Str::studly($name); $this->moduleSeed($this->getModuleByName($name)); } else { $modules = $this->getModuleRepository()->getOrdered(); array_walk($modules, [$this, 'moduleSeed']); $this->info('All modules seeded.'); } } catch (\Error $e) { $e = new ErrorException($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e); $this->reportException($e); $this->renderException($this->getOutput(), $e); return E_ERROR; } catch (\Exception $e) { $this->reportException($e); $this->renderException($this->getOutput(), $e); return E_ERROR; } return 0; } /** * @throws RuntimeException * @return RepositoryInterface */ public function getModuleRepository(): RepositoryInterface { $modules = $this->laravel['modules']; if (!$modules instanceof RepositoryInterface) { throw new RuntimeException('Module repository not found!'); } return $modules; } /** * @param $name * * @throws RuntimeException * * @return Module */ public function getModuleByName($name) { $modules = $this->getModuleRepository(); if ($modules->has($name) === false) { throw new RuntimeException("Module [$name] does not exists."); } return $modules->find($name); } /** * @param Module $module * * @return void */ public function moduleSeed(Module $module) { $seeders = []; $name = $module->getName(); $config = $module->get('migration'); if (is_array($config) && array_key_exists('seeds', $config)) { foreach ((array)$config['seeds'] as $class) { if (class_exists($class)) { $seeders[] = $class; } } } else { $class = $this->getSeederName($name); //legacy support if (class_exists($class)) { $seeders[] = $class; } else { //look at other namespaces $classes = $this->getSeederNames($name); foreach ($classes as $class) { if (class_exists($class)) { $seeders[] = $class; } } } } if (count($seeders) > 0) { array_walk($seeders, [$this, 'dbSeed']); $this->info("Module [$name] seeded."); } } /** * Seed the specified module. * * @param string $className */ protected function dbSeed($className) { if ($option = $this->option('class')) { $params['--class'] = Str::finish(substr($className, 0, strrpos($className, '\\')), '\\') . $option; } else { $params = ['--class' => $className]; } if ($option = $this->option('database')) { $params['--database'] = $option; } if ($option = $this->option('force')) { $params['--force'] = $option; } $this->call('db:seed', $params); } /** * Get master database seeder name for the specified module. * * @param string $name * * @return string */ public function getSeederName($name) { $name = Str::studly($name); $namespace = $this->laravel['modules']->config('namespace'); $config = GenerateConfigReader::read('seeder'); $seederPath = str_replace('/', '\\', $config->getPath()); return $namespace . '\\' . $name . '\\' . $seederPath . '\\' . $name . 'DatabaseSeeder'; } /** * Get master database seeder name for the specified module under a different namespace than Modules. * * @param string $name * * @return array $foundModules array containing namespace paths */ public function getSeederNames($name) { $name = Str::studly($name); $seederPath = GenerateConfigReader::read('seeder'); $seederPath = str_replace('/', '\\', $seederPath->getPath()); $foundModules = []; foreach ($this->laravel['modules']->config('scan.paths') as $path) { $namespace = array_slice(explode('/', $path), -1)[0]; $foundModules[] = $namespace . '\\' . $name . '\\' . $seederPath . '\\' . $name . 'DatabaseSeeder'; } return $foundModules; } /** * Report the exception to the exception handler. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void */ protected function renderException($output, \Exception $e) { $this->laravel[ExceptionHandler::class]->renderForConsole($output, $e); } /** * Report the exception to the exception handler. * * @param \Throwable $e * @return void */ protected function reportException(\Exception $e) { $this->laravel[ExceptionHandler::class]->report($e); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ]; } } PKZPҌ 4laravel-modules/src/Commands/ListenerMakeCommand.phpnu[laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ 'NAMESPACE' => $this->getClassNamespace($module), 'EVENTNAME' => $this->getEventName($module), 'SHORTEVENTNAME' => $this->getShortEventName(), 'CLASS' => $this->getClass(), ]))->render(); } public function getDefaultNamespace(): string { $module = $this->laravel['modules']; return $module->config('paths.generator.listener.namespace') ?: $module->config('paths.generator.listener.path', 'Listeners'); } protected function getEventName(Module $module) { $namespace = $this->laravel['modules']->config('namespace') . "\\" . $module->getStudlyName(); $eventPath = GenerateConfigReader::read('event'); $eventName = $namespace . "\\" . $eventPath->getPath() . "\\" . $this->option('event'); return str_replace('/', '\\', $eventName); } protected function getShortEventName() { return class_basename($this->option('event')); } protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $listenerPath = GenerateConfigReader::read('listener'); return $path . $listenerPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ protected function getFileName() { return Str::studly($this->argument('name')); } /** * @return string */ protected function getStubName(): string { if ($this->option('queued')) { if ($this->option('event')) { return '/listener-queued.stub'; } return '/listener-queued-duck.stub'; } if ($this->option('event')) { return '/listener.stub'; } return '/listener-duck.stub'; } } PKZUCQQ<laravel-modules/src/Commands/PublishConfigurationCommand.phpnu[components->info('publishing module config files...'); if ($module = $this->argument('module')) { $this->publishConfiguration($module); return 0; } foreach ($this->laravel['modules']->allEnabled() as $module) { $this->publishConfiguration($module->getName()); } return 0; } /** * @param string $module * @return string */ private function getServiceProviderForModule($module) { $namespace = $this->laravel['config']->get('modules.namespace'); $studlyName = Str::studly($module); return "$namespace\\$studlyName\\Providers\\{$studlyName}ServiceProvider"; } /** * @param string $module */ private function publishConfiguration($module) { $this->call('vendor:publish', [ '--provider' => $this->getServiceProviderForModule($module), '--force' => $this->option('force'), '--tag' => ['config'], ]); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module being used.'], ]; } /** * @return array */ protected function getOptions() { return [ ['--force', '-f', InputOption::VALUE_NONE, 'Force the publishing of config files'], ]; } } PKZH2;;.laravel-modules/src/Commands/UpdateCommand.phpnu[components->info('Updating module ...'); if ($name = $this->argument('module')) { $this->updateModule($name); return 0; } $this->updateAllModule(); return 0; } protected function updateAllModule() { /** @var \Nwidart\Modules\Module $module */ $modules = $this->laravel['modules']->getOrdered(); foreach ($modules as $module) { $this->updateModule($module); } } protected function updateModule($name) { if ($name instanceof Module) { $module = $name; }else { $module = $this->laravel['modules']->findOrFail($name); } $this->components->task("Updating {$module->getName()} module", function () use ($module) { $this->laravel['modules']->update($module); }); $this->laravel['modules']->update($name); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be updated.'], ]; } } PKZn]U  3laravel-modules/src/Commands/FactoryMakeCommand.phpnu[laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/factory.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'NAME' => $this->getModelName(), 'MODEL_NAMESPACE' => $this->getModelNamespace(), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $factoryPath = GenerateConfigReader::read('factory'); return $path . $factoryPath->getPath() . '/' . $this->getFileName(); } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')) . 'Factory.php'; } /** * @return mixed|string */ private function getModelName() { return Str::studly($this->argument('name')); } /** * Get default namespace. * * @return string */ public function getDefaultNamespace(): string { $module = $this->laravel['modules']; return $module->config('paths.generator.factory.namespace') ?: $module->config('paths.generator.factory.path'); } /** * Get model namespace. * * @return string */ public function getModelNamespace(): string { $path = $this->laravel['modules']->config('paths.generator.model.path', 'Entities'); $path = str_replace('/', '\\', $path); return $this->laravel['modules']->config('namespace') . '\\' . $this->laravel['modules']->findOrFail($this->getModuleName()) . '\\' . $path; } } PKZL&,laravel-modules/src/Commands/DumpCommand.phpnu[components->info('Generating optimized autoload modules.'); if ($name = $this->argument('module') ) { $this->dump($name); return 0; } $this->dumpAll(); return 0; } /** * dumpAll * * @return void */ public function dumpAll() { /** @var Modules $modules */ $modules = $this->laravel['modules']->all(); foreach ($modules as $module) { $this->dump($module); } } public function dump($name) { if ($name instanceof Module) { $module = $name; } else { $module = $this->laravel['modules']->findOrFail($name); } $this->components->task("$module", function () use ($module) { chdir($module->getPath()); passthru('composer dump -o -n -q'); }); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'Module name.'], ]; } } PKZQߨ1laravel-modules/src/Commands/EventMakeCommand.phpnu[laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/event.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } public function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $eventPath = GenerateConfigReader::read('event'); return $path . $eventPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ protected function getFileName() { return Str::studly($this->argument('name')); } public function getDefaultNamespace(): string { $module = $this->laravel['modules']; return $module->config('paths.generator.event.namespace') ?: $module->config('paths.generator.event.path', 'Events'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the event.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } } PKZ(L 7laravel-modules/src/Commands/MigrateRollbackCommand.phpnu[module = $this->laravel['modules']; $name = $this->argument('module'); if (!empty($name)) { $this->rollback($name); return 0; } foreach ($this->module->getOrdered($this->option('direction')) as $module) { $this->line('Running for module: ' . $module->getName() . ''); $this->rollback($module); } return 0; } /** * Rollback migration from the specified module. * * @param $module */ public function rollback($module) { if (is_string($module)) { $module = $this->module->findOrFail($module); } $migrator = new Migrator($module, $this->getLaravel(), $this->option('subpath')); $database = $this->option('database'); if (!empty($database)) { $migrator->setDatabase($database); } $migrated = $migrator->rollback(); if (count($migrated)) { foreach ($migrated as $migration) { $this->line("Rollback: {$migration}"); } return; } $this->comment('Nothing to rollback.'); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'desc'], ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], ['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath for modules specific migration file'] ]; } } PKZW  /laravel-modules/src/Commands/MigrateCommand.phpnu[module = $this->laravel['modules']; $name = $this->argument('module'); if ($name) { $module = $this->module->findOrFail($name); $this->migrate($module); return 0; } foreach ($this->module->getOrdered($this->option('direction')) as $module) { $this->line('Running for module: ' . $module->getName() . ''); $this->migrate($module); } return 0; } /** * Run the migration from the specified module. * * @param Module $module */ protected function migrate(Module $module) { $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath()); if ($this->option('subpath')) { $path = $path . "/" . $this->option("subpath"); } $this->call('migrate', [ '--path' => $path, '--database' => $this->option('database'), '--pretend' => $this->option('pretend'), '--force' => $this->option('force'), ]); if ($this->option('seed')) { $this->call('module:seed', ['module' => $module->getName(), '--force' => $this->option('force')]); } } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], ['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath to run your migrations from'], ]; } } PKZ؟8laravel-modules/src/Commands/NotificationMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.notifications.namespace') ?: $module->config('paths.generator.notifications.path', 'Notifications'); } /** * Get template contents. * * @return string */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/notification.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * Get the destination file path. * * @return string */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $notificationPath = GenerateConfigReader::read('notifications'); return $path . $notificationPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the notification class.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } } PKZ@ Y:--.laravel-modules/src/Commands/EnableCommand.phpnu[components->info('Enabling module ...'); if ($name = $this->argument('module') ) { $this->enable($name); return 0; } $this->enableAll(); return 0; } /** * enableAll * * @return void */ public function enableAll() { /** @var Modules $modules */ $modules = $this->laravel['modules']->all(); foreach ($modules as $module) { $this->enable($module); } } /** * enable * * @param string $name * @return void */ public function enable($name) { if ($name instanceof Module) { $module = $name; }else { $module = $this->laravel['modules']->findOrFail($name); } if ($module->isDisabled()) { $module->enable(); $this->components->info("Module [{$module}] enabled successful."); }else { $this->components->warn("Module [{$module}] has already enabled."); } } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'Module name.'], ]; } } PKZ<9,laravel-modules/src/Commands/ListCommand.phpnu[components->twoColumnDetail('Status / Name', 'Path / priority'); collect($this->getRows())->each(function ($row) { $this->components->twoColumnDetail("[{$row[1]}] {$row[0]}", "{$row[3]} [{$row[2]}]"); }); return 0; } /** * Get table rows. * * @return array */ public function getRows() { $rows = []; /** @var Module $module */ foreach ($this->getModules() as $module) { $rows[] = [ $module->getName(), $module->isEnabled() ? 'Enabled' : 'Disabled', $module->get('priority'), $module->getPath(), ]; } return $rows; } public function getModules() { switch ($this->option('only')) { case 'enabled': return $this->laravel['modules']->getByStatus(1); break; case 'disabled': return $this->laravel['modules']->getByStatus(0); break; case 'priority': return $this->laravel['modules']->getPriority($this->option('direction')); break; default: return $this->laravel['modules']->all(); break; } } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['only', 'o', InputOption::VALUE_OPTIONAL, 'Types of modules will be displayed.', null], ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], ]; } } PKZ`AA/laravel-modules/src/Commands/PublishCommand.phpnu[components->info('Publishing module assets...'); if ($name = $this->argument('module')) { $this->publish($name); return 0; } $this->publishAll(); return 0; } /** * Publish assets from all modules. */ public function publishAll() { foreach ($this->laravel['modules']->allEnabled() as $module) { $this->publish($module); } } /** * Publish assets from the specified module. * * @param string $name */ public function publish($name) { if ($name instanceof Module) { $module = $name; } else { $module = $this->laravel['modules']->findOrFail($name); } with(new AssetPublisher($module)) ->setRepository($this->laravel['modules']) ->setConsole($this) ->publish(); $this->components->task($module->getStudlyName(), fn()=>true); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } } PKZP=Hxx4laravel-modules/src/Commands/MigrateFreshCommand.phpnu[argument('module'); if ($module && !$this->getModuleName()) { $this->error("Module [$module] does not exists."); return E_ERROR; } $this->call('migrate:fresh'); $this->call('module:migrate', [ 'module' => $this->getModuleName(), '--database' => $this->option('database'), '--force' => $this->option('force'), '--seed' => $this->option('seed'), ]); return 0; } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], ]; } public function getModuleName() { $module = $this->argument('module'); if (!$module) { return null; } $module = app('modules')->find($module); return $module ? $module->getStudlyName() : null; } } PKZkxx-laravel-modules/src/Commands/UnUseCommand.phpnu[laravel['modules']->forgetUsed(); $this->components->info('Previous module used successfully forgotten.'); return 0; } } PKZq/laravel-modules/src/Commands/DisableCommand.phpnu[components->info('Disabling module ...'); if (count($this->argument('module'))) { foreach($this->argument('module') as $name) { $this->disable($name); } return 0; } $this->disableAll(); return 0; } /** * disableAll * * @return void */ public function disableAll() { /** @var Modules $modules */ $modules = $this->laravel['modules']->all(); foreach ($modules as $module) { $this->disable($module); } } /** * disable * * @param string $name * @return void */ public function disable($name) { if ($name instanceof Module) { $module = $name; }else { $module = $this->laravel['modules']->findOrFail($name); } if ($module->isEnabled()) { $module->disable(); $this->components->info("Module [{$module}] disabled successful."); } else { $this->components->warn("Module [{$module}] has already disabled."); } } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'Module name.'], ]; } } PKZ7laravel-modules/src/Commands/stubs/assets/sass/app.stubnu[PKZ5laravel-modules/src/Commands/stubs/assets/js/app.stubnu[PKZFZdd2laravel-modules/src/Commands/stubs/middleware.stubnu[call("OthersTableSeeder"); } } PKZ 23laravel-modules/src/Commands/stubs/views/index.stubnu[@extends('$LOWER_NAME$::layouts.master') @section('content')

Hello World

This view is loaded from module: {!! config('$LOWER_NAME$.name') !!}

@endsection PKZ5OO4laravel-modules/src/Commands/stubs/views/master.stubnu[ Module $STUDLY_NAME$ {{-- Laravel Vite - CSS File --}} {{-- {{ module_vite('build-$LOWER_NAME$', 'Resources/assets/sass/app.scss') }} --}} @yield('content') {{-- Laravel Vite - JS File --}} {{-- {{ module_vite('build-$LOWER_NAME$', 'Resources/assets/js/app.js') }} --}} PKZ8UU0laravel-modules/src/Commands/stubs/resource.stubnu[ PKZD=-laravel-modules/src/Commands/stubs/event.stubnu[assertTrue(true); } } PKZ}^ 7laravel-modules/src/Commands/stubs/component-class.stubnu[line('The introduction to the notification.') ->action('Notification Action', 'https://laravel.com') ->line('Thank you for using our application!'); } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { return [ // ]; } } PKZL/laravel-modules/src/Commands/stubs/request.stubnu[get('/'); $response->assertStatus(200); } } PKZ, UU2laravel-modules/src/Commands/stubs/job-queued.stubnu[group(function() { Route::get('/', '$STUDLY_NAME$Controller@index'); }); PKZ;HT2laravel-modules/src/Commands/stubs/routes/api.stubnu[get('/$LOWER_NAME$', function (Request $request) { return $request->user(); });PKZ67laravel-modules/src/Commands/stubs/migration/plain.stubnu[bigIncrements('id'); $FIELDS$ $table->timestamps(); }); } }; PKZ FF8laravel-modules/src/Commands/stubs/migration/create.stubnu[id(); $FIELDS$ $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('$TABLE$'); } }; PKZ#g,laravel-modules/src/Commands/stubs/mail.stubnu[view('view.name'); } } PKZK 9laravel-modules/src/Commands/stubs/scaffold/provider.stubnu[registerTranslations(); $this->registerConfig(); $this->registerViews(); $this->loadMigrationsFrom(module_path($this->moduleName, '$MIGRATIONS_PATH$')); } /** * Register the service provider. * * @return void */ public function register() { $this->app->register(RouteServiceProvider::class); } /** * Register config. * * @return void */ protected function registerConfig() { $this->publishes([ module_path($this->moduleName, '$PATH_CONFIG$/config.php') => config_path($this->moduleNameLower . '.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, '$PATH_CONFIG$/config.php'), $this->moduleNameLower ); } /** * Register views. * * @return void */ public function registerViews() { $viewPath = resource_path('views/modules/' . $this->moduleNameLower); $sourcePath = module_path($this->moduleName, '$PATH_VIEWS$'); $this->publishes([ $sourcePath => $viewPath ], ['views', $this->moduleNameLower . '-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. * * @return void */ public function registerTranslations() { $langPath = resource_path('lang/modules/' . $this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { $this->loadTranslationsFrom(module_path($this->moduleName, '$PATH_LANG$'), $this->moduleNameLower); $this->loadJsonTranslationsFrom(module_path($this->moduleName, '$PATH_LANG$')); } } /** * Get the services provided by the provider. * * @return array */ public function provides() { return []; } private function getPublishableViewPaths(): array { $paths = []; foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } } return $paths; } } PKZ"(:117laravel-modules/src/Commands/stubs/scaffold/config.stubnu[ '$STUDLY_NAME$' ]; PKZ0 6laravel-modules/src/Commands/stubs/route-provider.stubnu[mapApiRoutes(); $this->mapWebRoutes(); } /** * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. * * @return void */ protected function mapWebRoutes() { Route::middleware('web') ->namespace($this->moduleNamespace) ->group(module_path('$MODULE$', '$WEB_ROUTES_PATH$')); } /** * Define the "api" routes for the application. * * These routes are typically stateless. * * @return void */ protected function mapApiRoutes() { Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) ->group(module_path('$MODULE$', '$API_ROUTES_PATH$')); } } PKZ`  4laravel-modules/src/Commands/stubs/policy.plain.stubnu[langPath = DIRECTORY_SEPARATOR . config('modules.paths.generator.lang.path', 'Resources/lang'); $this->components->alert('Checking languages ...'); $this->newLine(); if ($name = $this->argument('module')) { $this->check($name); return 0; } $this->checkAll(); return 0; } /** * enableAll * * @return void */ public function checkAll() { $modules = $this->laravel['modules']->all(); foreach ($modules as $module) { $this->check($module); } } /** * enable * * @param string $name * @return void */ public function check($name) { if ($name instanceof Module) { $module = $name; } else { $module = $this->laravel['modules']->findOrFail($name); } $directories = $this->getDirectories($module); if (! $directories) { return; } $this->checkMissingFiles($directories); $this->checkMissingKeys($directories); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['module', InputArgument::OPTIONAL, 'Module name.'], ]; } private function getLangFiles($module) { $files = []; $path = $module->getPath() . $this->langPath; if (is_dir($path)) { $files = array_merge($files, $this->laravel['files']->all($path)); } return $files; } private function getDirectories($module) { $moduleName = $module->getStudlyName(); $path = $module->getPath() . '/Resources/lang'; if (is_dir($path)) { $directories = $this->laravel['files']->directories($path); $directories = array_map(function ($directory) use ($moduleName) { return [ 'name' => basename($directory), 'module' => $moduleName, 'path' => $directory, 'files' => array_map(function ($file) { return basename($file); }, \File::glob($directory . DIRECTORY_SEPARATOR . "*")), ]; }, $directories); } if (count($directories) == 0) { $this->components->info("No language files found in module $moduleName"); return false; } if (count($directories) == 1) { $this->components->warn("Only one language file found in module $moduleName"); return false; } return collect($directories); } private function checkMissingFiles(Collection $directories) { //show missing files $missingFilesMessage = []; $uniqeLangFiles = $directories->pluck('files')->flatten()->unique()->values(); $directories->each(function ($directory) use ($uniqeLangFiles, &$missingFilesMessage) { $missingFiles = $uniqeLangFiles->diff($directory['files']); if ($missingFiles->count() > 0) { $missingFiles->each(function ($missingFile) use ($directory, &$missingFilesMessage) { $missingFilesMessage[$directory['name']][] = " {$directory['module']} - Missing language file: {$directory['name']}/{$missingFile}"; }); } }); if (count($missingFilesMessage) > 0) { collect($missingFilesMessage)->each(function ($messages, $langDirectory) { $this->components->error("Missing language files in $langDirectory directory"); $this->components->bulletList( collect($messages)->unique()->values()->toArray() ); $this->newLine(); }); } } private function checkMissingKeys(Collection $directories) { //show missing keys $uniqeLangFiles = $directories->pluck('files')->flatten()->unique(); $langDirectories = $directories->pluck('name'); $missingKeysMessage = []; $directories->each(function ($directory) use ($uniqeLangFiles, $langDirectories, &$missingKeysMessage) { $uniqeLangFiles->each(function ($file) use ($directory, $langDirectories, &$missingKeysMessage) { $langKeys = $this->getLangKeys($directory['path'] . DIRECTORY_SEPARATOR . $file); if ($langKeys == false) { return; } $langDirectories->each(function ($langDirectory) use ($directory, $file, $langKeys, &$missingKeysMessage) { if ($directory['name'] != $langDirectory) { $basePath = str_replace($directory['name'], $langDirectory, $directory['path']); $otherLangKeys = $this->getLangKeys($basePath . DIRECTORY_SEPARATOR . $file); if ($otherLangKeys == false) { return; } $missingKeys = $langKeys->diff($otherLangKeys); if ($missingKeys->count() > 0) { $missingKeys->each(function ($missingKey) use ($directory, $langDirectory, $file, &$missingKeysMessage) { $missingKeysMessage[$langDirectory][] = " {$directory['module']} - Missing language key: {$langDirectory}/{$file} | key: $missingKey"; }); } } }); }); }); if (count($missingKeysMessage) > 0) { collect($missingKeysMessage)->each(function ($messages, $langDirectory) { $this->components->error("Missing language keys for directory $langDirectory:"); $this->components->bulletList( collect($messages)->unique()->values()->toArray() ); $this->newLine(); }); } } private function getLangKeys($file) { if (\File::exists($file)) { $lang = \File::getRequire($file); return collect(\Arr::dot($lang))->keys(); } else { return false; } } } PKZaG  0laravel-modules/src/Commands/SeedMakeCommand.phpnu[laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/seeder.stub', [ 'NAME' => $this->getSeederName(), 'MODULE' => $this->getModuleName(), 'NAMESPACE' => $this->getClassNamespace($module), ]))->render(); } /** * @return mixed */ protected function getDestinationFilePath() { $this->clearCache(); $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $seederPath = GenerateConfigReader::read('seeder'); return $path . $seederPath->getPath() . '/' . $this->getSeederName() . '.php'; } /** * Get seeder name. * * @return string */ private function getSeederName() { $end = $this->option('master') ? 'DatabaseSeeder' : 'TableSeeder'; return Str::studly($this->argument('name')) . $end; } /** * Get default namespace. * * @return string */ public function getDefaultNamespace(): string { $module = $this->laravel['modules']; return $module->config('paths.generator.seeder.namespace') ?: $module->config('paths.generator.seeder.path', 'Database/Seeders'); } } PKZ\5rr3laravel-modules/src/Commands/ChannelMakeCommand.phpnu[laravel['modules']; return $module->config('paths.generator.channels.namespace') ?: $module->config('paths.generator.channels.path', 'Broadcasting'); } /** * Get template contents. * * @return string */ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/channel.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), ]))->render(); } /** * Get the destination file path. * * @return string */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $channelPath = GenerateConfigReader::read('channels'); return $path . $channelPath->getPath() . '/' . $this->getFileName() . '.php'; } /** * @return string */ private function getFileName() { return Str::studly($this->argument('name')); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the channel class.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } } PKZaN/5laravel-modules/src/Publishing/MigrationPublisher.phpnu[migrator = $migrator; parent::__construct($migrator->getModule()); } /** * Get destination path. * * @return string */ public function getDestinationPath() { return $this->repository->config('paths.migration'); } /** * Get source path. * * @return string */ public function getSourcePath() { return $this->migrator->getPath(); } } PKZM,laravel-modules/src/Publishing/Publisher.phpnu[module = $module; } /** * Show the result message. * * @return self */ public function showMessage() { $this->showMessage = true; return $this; } /** * Hide the result message. * * @return self */ public function hideMessage() { $this->showMessage = false; return $this; } /** * Get module instance. * * @return \Nwidart\Modules\Module */ public function getModule() { return $this->module; } /** * Set modules repository instance. * @param RepositoryInterface $repository * @return $this */ public function setRepository(RepositoryInterface $repository) { $this->repository = $repository; return $this; } /** * Get modules repository instance. * * @return RepositoryInterface */ public function getRepository() { return $this->repository; } /** * Set console instance. * * @param \Illuminate\Console\Command $console * * @return $this */ public function setConsole(Command $console) { $this->console = $console; return $this; } /** * Get console instance. * * @return \Illuminate\Console\Command */ public function getConsole() { return $this->console; } /** * Get laravel filesystem instance. * * @return \Illuminate\Filesystem\Filesystem */ public function getFilesystem() { return $this->repository->getFiles(); } /** * Get destination path. * * @return string */ abstract public function getDestinationPath(); /** * Get source path. * * @return string */ abstract public function getSourcePath(); /** * Publish something. */ public function publish() { if (!$this->console instanceof Command) { $message = "The 'console' property must instance of \\Illuminate\\Console\\Command."; throw new \RuntimeException($message); } if (!$this->getFilesystem()->isDirectory($sourcePath = $this->getSourcePath())) { return; } if (!$this->getFilesystem()->isDirectory($destinationPath = $this->getDestinationPath())) { $this->getFilesystem()->makeDirectory($destinationPath, 0775, true); } if ($this->getFilesystem()->copyDirectory($sourcePath, $destinationPath)) { if ($this->showMessage === true) { $this->console->components->task($this->module->getStudlyName(), fn() => true); } } else { $this->console->components->task($this->module->getStudlyName(), fn() => false); $this->console->components->error($this->error); } } } PKZXل0laravel-modules/src/Publishing/LangPublisher.phpnu[module->getLowerName(); return base_path("resources/lang/{$name}"); } /** * Get source path. * * @return string */ public function getSourcePath() { return $this->getModule()->getExtraPath( GenerateConfigReader::read('lang')->getPath() ); } } PKZ@9x1laravel-modules/src/Publishing/AssetPublisher.phpnu[repository->assetPath($this->module->getLowerName()); } /** * Get source path. * * @return string */ public function getSourcePath() { return $this->getModule()->getExtraPath( GenerateConfigReader::read('assets')->getPath() ); } } PKZ<&冴laravel-modules/src/helpers.phpnu[find($name); return $module->getPath() . ($path ? DIRECTORY_SEPARATOR . $path : $path); } } if (! function_exists('config_path')) { /** * Get the configuration path. * * @param string $path * @return string */ function config_path($path = '') { return app()->basePath() . '/config' . ($path ? DIRECTORY_SEPARATOR . $path : $path); } } if (! function_exists('public_path')) { /** * Get the path to the public folder. * * @param string $path * @return string */ function public_path($path = '') { return app()->make('path.public') . ($path ? DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR) : $path); } } if (! function_exists('module_vite')) { /** * support for vite */ function module_vite($module, $asset): Vite { return ViteFacade::useHotFile(storage_path('vite.hot'))->useBuildDirectory($module)->withEntryPoints([$asset]); } } PKZn[|jUU.laravel-modules/src/ModulesServiceProvider.phpnu[app->register(BootstrapServiceProvider::class); } /** * Register package's namespaces. */ protected function registerNamespaces() { $configPath = __DIR__ . '/../config/config.php'; $stubsPath = dirname(__DIR__) . '/src/Commands/stubs'; $this->publishes([ $configPath => config_path('modules.php'), ], 'config'); $this->publishes([ $stubsPath => base_path('stubs/nwidart-stubs'), ], 'stubs'); } /** * Register the service provider. */ abstract protected function registerServices(); /** * Get the services provided by the provider. * * @return array */ public function provides() { return [Contracts\RepositoryInterface::class, 'modules']; } /** * Register providers. */ protected function registerProviders() { $this->app->register(ConsoleServiceProvider::class); $this->app->register(ContractsServiceProvider::class); } } PKZiUBB&laravel-modules/src/Facades/Module.phpnu[registerNamespaces(); $this->registerModules(); } /** * Register the service provider. */ public function register() { $this->registerServices(); $this->setupStubPath(); $this->registerProviders(); $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'modules'); } /** * Setup stub path. */ public function setupStubPath() { $path = $this->app['config']->get('modules.stubs.path') ?? __DIR__ . '/Commands/stubs'; Stub::setBasePath($path); $this->app->booted(function ($app) { /** @var RepositoryInterface $moduleRepository */ $moduleRepository = $app[RepositoryInterface::class]; if ($moduleRepository->config('stubs.enabled') === true) { Stub::setBasePath($moduleRepository->config('stubs.path')); } }); } /** * {@inheritdoc} */ protected function registerServices() { $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) { $path = $app['config']->get('modules.paths.modules'); return new Laravel\LaravelFileRepository($app, $path); }); $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { $activator = $app['config']->get('modules.activator'); $class = $app['config']->get('modules.activators.' . $activator)['class']; if ($class === null) { throw InvalidActivatorClass::missingConfig(); } return new $class($app); }); $this->app->alias(Contracts\RepositoryInterface::class, 'modules'); } } PKZ&v찤:laravel-modules/src/Providers/ContractsServiceProvider.phpnu[app->bind(RepositoryInterface::class, LaravelFileRepository::class); } } PKZLc^:laravel-modules/src/Providers/BootstrapServiceProvider.phpnu[app[RepositoryInterface::class]->boot(); } /** * Register the provider. */ public function register(): void { $this->app[RepositoryInterface::class]->register(); } } PKZu 8laravel-modules/src/Providers/ConsoleServiceProvider.phpnu[commands(config('modules.commands', $this->commands)); } public function provides(): array { return $this->commands; } } PKZ!;;"laravel-modules/src/Collection.phpnu[items; } /** * Get the collection of items as a plain array. * * @return array */ public function toArray() { return array_map(function ($value) { if ($value instanceof Module) { $attributes = $value->json()->getAttributes(); $attributes["path"] = $value->getPath(); return $attributes; } return $value instanceof Arrayable ? $value->toArray() : $value; }, $this->items); } } PKZ$T@31laravel-modules/src/Lumen/LumenFileRepository.phpnu[getSnakeName() . '_module.php', $this->app->basePath('storage/app/') . 'services.php'); } /** * {@inheritdoc} */ public function registerProviders(): void { foreach ($this->get('providers', []) as $provider) { $this->app->register($provider); } } /** * {@inheritdoc} */ public function registerAliases(): void { } } PKZX>3laravel-modules/src/LumenModulesServiceProvider.phpnu[setupStubPath(); } /** * Register all modules. */ public function register() { $this->registerNamespaces(); $this->registerServices(); $this->registerModules(); $this->registerProviders(); } /** * Setup stub path. */ public function setupStubPath() { Stub::setBasePath(__DIR__ . '/Commands/stubs'); if (app('modules')->config('stubs.enabled') === true) { Stub::setBasePath(app('modules')->config('stubs.path')); } } /** * {@inheritdoc} */ protected function registerServices() { $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) { $path = $app['config']->get('modules.paths.modules'); return new Lumen\LumenFileRepository($app, $path); }); $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { $activator = $app['config']->get('modules.activator'); $class = $app['config']->get('modules.activators.' . $activator)['class']; return new $class($app); }); $this->app->alias(Contracts\RepositoryInterface::class, 'modules'); } } PKZk&[3[3&laravel-modules/src/FileRepository.phpnu[app = $app; $this->path = $path; $this->url = $app['url']; $this->config = $app['config']; $this->files = $app['files']; $this->cache = $app['cache']; } /** * Add other module location. * * @param string $path * * @return $this */ public function addLocation($path) { $this->paths[] = $path; return $this; } /** * Get all additional paths. * * @return array */ public function getPaths(): array { return $this->paths; } /** * Get scanned modules paths. * * @return array */ public function getScanPaths(): array { $paths = $this->paths; $paths[] = $this->getPath(); if ($this->config('scan.enabled')) { $paths = array_merge($paths, $this->config('scan.paths')); } $paths = array_map(function ($path) { return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); }, $paths); return $paths; } /** * Creates a new Module instance * * @param Container $app * @param string $args * @param string $path * @return \Nwidart\Modules\Module */ abstract protected function createModule(...$args); /** * Get & scan all modules. * * @return array */ public function scan() { $paths = $this->getScanPaths(); $modules = []; foreach ($paths as $key => $path) { $manifests = $this->getFiles()->glob("{$path}/module.json"); is_array($manifests) || $manifests = []; foreach ($manifests as $manifest) { $name = Json::make($manifest)->get('name'); $modules[$name] = $this->createModule($this->app, $name, dirname($manifest)); } } return $modules; } /** * Get all modules. * * @return array */ public function all(): array { if (!$this->config('cache.enabled')) { return $this->scan(); } return $this->formatCached($this->getCached()); } /** * Format the cached data as array of modules. * * @param array $cached * * @return array */ protected function formatCached($cached) { $modules = []; foreach ($cached as $name => $module) { $path = $module['path']; $modules[$name] = $this->createModule($this->app, $name, $path); } return $modules; } /** * Get cached modules. * * @return array */ public function getCached() { return $this->cache->store($this->config->get('modules.cache.driver'))->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () { return $this->toCollection()->toArray(); }); } /** * Get all modules as collection instance. * * @return Collection */ public function toCollection(): Collection { return new Collection($this->scan()); } /** * Get modules by status. * * @param $status * * @return array */ public function getByStatus($status): array { $modules = []; /** @var Module $module */ foreach ($this->all() as $name => $module) { if ($module->isStatus($status)) { $modules[$name] = $module; } } return $modules; } /** * Determine whether the given module exist. * * @param $name * * @return bool */ public function has($name): bool { return array_key_exists($name, $this->all()); } /** * Get list of enabled modules. * * @return array */ public function allEnabled(): array { return $this->getByStatus(true); } /** * Get list of disabled modules. * * @return array */ public function allDisabled(): array { return $this->getByStatus(false); } /** * Get count from all modules. * * @return int */ public function count(): int { return count($this->all()); } /** * Get all ordered modules. * * @param string $direction * * @return array */ public function getOrdered($direction = 'asc'): array { $modules = $this->allEnabled(); uasort($modules, function (Module $a, Module $b) use ($direction) { if ($a->get('priority') === $b->get('priority')) { return 0; } if ($direction === 'desc') { return $a->get('priority') < $b->get('priority') ? 1 : -1; } return $a->get('priority') > $b->get('priority') ? 1 : -1; }); return $modules; } /** * @inheritDoc */ public function getPath(): string { return $this->path ?: $this->config('paths.modules', base_path('Modules')); } /** * @inheritDoc */ public function register(): void { foreach ($this->getOrdered() as $module) { $module->register(); } } /** * @inheritDoc */ public function boot(): void { foreach ($this->getOrdered() as $module) { $module->boot(); } } /** * @inheritDoc */ public function find(string $name) { foreach ($this->all() as $module) { if ($module->getLowerName() === strtolower($name)) { return $module; } } return; } /** * Find a specific module, if there return that, otherwise throw exception. * * @param $name * * @return Module * * @throws ModuleNotFoundException */ public function findOrFail(string $name) { $module = $this->find($name); if ($module !== null) { return $module; } throw new ModuleNotFoundException("Module [{$name}] does not exist!"); } /** * Get all modules as laravel collection instance. * * @param $status * * @return Collection */ public function collections($status = 1): Collection { return new Collection($this->getByStatus($status)); } /** * Get module path for a specific module. * * @param $module * * @return string */ public function getModulePath($module) { try { return $this->findOrFail($module)->getPath() . '/'; } catch (ModuleNotFoundException $e) { return $this->getPath() . '/' . Str::studly($module) . '/'; } } /** * @inheritDoc */ public function assetPath(string $module): string { return $this->config('paths.assets') . '/' . $module; } /** * @inheritDoc */ public function config(string $key, $default = null) { return $this->config->get('modules.' . $key, $default); } /** * Get storage path for module used. * * @return string */ public function getUsedStoragePath(): string { $directory = storage_path('app/modules'); if ($this->getFiles()->exists($directory) === false) { $this->getFiles()->makeDirectory($directory, 0777, true); } $path = storage_path('app/modules/modules.used'); if (!$this->getFiles()->exists($path)) { $this->getFiles()->put($path, ''); } return $path; } /** * Set module used for cli session. * * @param $name * * @throws ModuleNotFoundException */ public function setUsed($name) { $module = $this->findOrFail($name); $this->getFiles()->put($this->getUsedStoragePath(), $module); } /** * Forget the module used for cli session. */ public function forgetUsed() { if ($this->getFiles()->exists($this->getUsedStoragePath())) { $this->getFiles()->delete($this->getUsedStoragePath()); } } /** * Get module used for cli session. * @return string * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ public function getUsedNow(): string { return $this->findOrFail($this->getFiles()->get($this->getUsedStoragePath())); } /** * Get laravel filesystem instance. * * @return Filesystem */ public function getFiles(): Filesystem { return $this->files; } /** * Get module assets path. * * @return string */ public function getAssetsPath(): string { return $this->config('paths.assets'); } /** * Get asset url from a specific module. * @param string $asset * @return string * @throws InvalidAssetPath */ public function asset($asset): string { if (Str::contains($asset, ':') === false) { throw InvalidAssetPath::missingModuleName($asset); } list($name, $url) = explode(':', $asset); $baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath()); $url = $this->url->asset($baseUrl . "/{$name}/" . $url); return str_replace(['http://', 'https://'], '//', $url); } /** * @inheritDoc */ public function isEnabled(string $name): bool { return $this->findOrFail($name)->isEnabled(); } /** * @inheritDoc */ public function isDisabled(string $name): bool { return !$this->isEnabled($name); } /** * Enabling a specific module. * @param string $name * @return void * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ public function enable($name) { $this->findOrFail($name)->enable(); } /** * Disabling a specific module. * @param string $name * @return void * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ public function disable($name) { $this->findOrFail($name)->disable(); } /** * @inheritDoc */ public function delete(string $name): bool { return $this->findOrFail($name)->delete(); } /** * Update dependencies for the specified module. * * @param string $module */ public function update($module) { with(new Updater($this))->update($module); } /** * Install the specified module. * * @param string $name * @param string $version * @param string $type * @param bool $subtree * * @return \Symfony\Component\Process\Process */ public function install($name, $version = 'dev-master', $type = 'composer', $subtree = false) { $installer = new Installer($name, $version, $type, $subtree); return $installer->run(); } /** * Get stub path. * * @return string|null */ public function getStubPath() { if ($this->stubPath !== null) { return $this->stubPath; } if ($this->config('stubs.enabled') === true) { return $this->config('stubs.path'); } return $this->stubPath; } /** * Set stub path. * * @param string $stubPath * * @return $this */ public function setStubPath($stubPath) { $this->stubPath = $stubPath; return $this; } } PKZQw4laravel-modules/src/Contracts/ActivatorInterface.phpnu[getSnakeName() . '_module.php', $this->app->getCachedConfigPath()); } return Str::replaceLast('services.php', $this->getSnakeName() . '_module.php', $this->app->getCachedServicesPath()); } /** * {@inheritdoc} */ public function registerProviders(): void { (new ProviderRepository($this->app, new Filesystem(), $this->getCachedServicesPath())) ->load($this->get('providers', [])); } /** * {@inheritdoc} */ public function registerAliases(): void { $loader = AliasLoader::getInstance(); foreach ($this->get('aliases', []) as $aliasName => $aliasClass) { $loader->alias($aliasName, $aliasClass); } } } PKZ<)f  5laravel-modules/src/Laravel/LaravelFileRepository.phpnu[ true, // Concatenation should be used with at least one whitespace around. 'concat_space' => ['spacing' => 'one'], // Unused use statements must be removed. 'ordered_imports' => true, // Removes extra empty lines. 'no_extra_blank_lines' => true, // An empty line feed should precede a return statement. 'blank_line_before_statement' => true, // Unused use statements must be removed. 'no_unused_imports' => true, // Remove trailing whitespace at the end of blank lines. 'no_whitespace_in_blank_line' => true, // There MUST be one blank line after the namespace declaration. 'blank_line_after_namespace' => true, // There should be exactly one blank line before a namespace declaration. 'single_blank_line_before_namespace' => true, // Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block. 'single_line_after_imports' => true, // Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline. 'blank_line_after_opening_tag' => true, // Remove duplicated semicolons. 'no_empty_statement' => true, // PHP multi-line arrays should have a trailing comma. 'trailing_comma_in_multiline' => true, // There should be no empty lines after class opening brace. 'no_blank_lines_after_class_opening' => true, // There should not be blank lines between docblock and the documented element. 'no_blank_lines_after_phpdoc' => true, // Phpdocs should start and end with content, excluding the very first and last line of the docblocks. 'phpdoc_trim' => true, ]; $finder = Finder::create() ->in(__DIR__) ->exclude([ 'vendor', 'tests/Commands/__snapshots__', ]) ->ignoreDotFiles(true) ->ignoreVCS(true); return (new Config()) ->setFinder($finder) ->setRules($rules) ->setRiskyAllowed(true) ->setUsingCache(true);PKZ(5

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable closeComment: false PKZ[??#laravel-modules/.github/FUNDING.ymlnu[# These are supported funding model platforms github: nwidart PKZÚ**!laravel-modules/config/config.phpnu[ 'Modules', /* |-------------------------------------------------------------------------- | Module Stubs |-------------------------------------------------------------------------- | | Default module stubs. | */ 'stubs' => [ 'enabled' => false, 'path' => base_path('vendor/nwidart/laravel-modules/src/Commands/stubs'), 'files' => [ 'routes/web' => 'Routes/web.php', 'routes/api' => 'Routes/api.php', 'views/index' => 'Resources/views/index.blade.php', 'views/master' => 'Resources/views/layouts/master.blade.php', 'scaffold/config' => 'Config/config.php', 'composer' => 'composer.json', 'assets/js/app' => 'Resources/assets/js/app.js', 'assets/sass/app' => 'Resources/assets/sass/app.scss', 'vite' => 'vite.config.js', 'package' => 'package.json', ], 'replacements' => [ 'routes/web' => ['LOWER_NAME', 'STUDLY_NAME'], 'routes/api' => ['LOWER_NAME'], 'vite' => ['LOWER_NAME'], 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], 'views/index' => ['LOWER_NAME'], 'views/master' => ['LOWER_NAME', 'STUDLY_NAME'], 'scaffold/config' => ['STUDLY_NAME'], 'composer' => [ 'LOWER_NAME', 'STUDLY_NAME', 'VENDOR', 'AUTHOR_NAME', 'AUTHOR_EMAIL', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE', ], ], 'gitkeep' => true, ], 'paths' => [ /* |-------------------------------------------------------------------------- | Modules path |-------------------------------------------------------------------------- | | This path used for save the generated module. This path also will be added | automatically to list of scanned folders. | */ 'modules' => base_path('Modules'), /* |-------------------------------------------------------------------------- | Modules assets path |-------------------------------------------------------------------------- | | Here you may update the modules assets path. | */ 'assets' => public_path('modules'), /* |-------------------------------------------------------------------------- | The migrations path |-------------------------------------------------------------------------- | | Where you run 'module:publish-migration' command, where do you publish the | the migration files? | */ 'migration' => base_path('database/migrations'), /* |-------------------------------------------------------------------------- | Generator path |-------------------------------------------------------------------------- | Customise the paths where the folders will be generated. | Set the generate key to false to not generate that folder */ 'generator' => [ 'config' => ['path' => 'Config', 'generate' => true], 'command' => ['path' => 'Console', 'generate' => true], 'channels' => ['path' => 'Broadcasting', 'generate' => true], 'migration' => ['path' => 'Database/Migrations', 'generate' => true], 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], 'factory' => ['path' => 'Database/factories', 'generate' => true], 'model' => ['path' => 'Entities', 'generate' => true], 'observer' => ['path' => 'Observers', 'generate' => true], 'routes' => ['path' => 'Routes', 'generate' => true], 'controller' => ['path' => 'Http/Controllers', 'generate' => true], 'filter' => ['path' => 'Http/Middleware', 'generate' => true], 'request' => ['path' => 'Http/Requests', 'generate' => true], 'provider' => ['path' => 'Providers', 'generate' => true], 'assets' => ['path' => 'Resources/assets', 'generate' => true], 'lang' => ['path' => 'Resources/lang', 'generate' => true], 'views' => ['path' => 'Resources/views', 'generate' => true], 'test' => ['path' => 'Tests/Unit', 'generate' => true], 'test-feature' => ['path' => 'Tests/Feature', 'generate' => true], 'repository' => ['path' => 'Repositories', 'generate' => false], 'event' => ['path' => 'Events', 'generate' => false], 'listener' => ['path' => 'Listeners', 'generate' => false], 'policies' => ['path' => 'Policies', 'generate' => false], 'rules' => ['path' => 'Rules', 'generate' => false], 'jobs' => ['path' => 'Jobs', 'generate' => false], 'emails' => ['path' => 'Emails', 'generate' => false], 'notifications' => ['path' => 'Notifications', 'generate' => false], 'resource' => ['path' => 'Transformers', 'generate' => false], 'component-view' => ['path' => 'Resources/views/components', 'generate' => false], 'component-class' => ['path' => 'View/Components', 'generate' => false], ], ], /* |-------------------------------------------------------------------------- | Package commands |-------------------------------------------------------------------------- | | Here you can define which commands will be visible and used in your | application. If for example you don't use some of the commands provided | you can simply comment them out. | */ 'commands' => [ Commands\CommandMakeCommand::class, Commands\ComponentClassMakeCommand::class, Commands\ComponentViewMakeCommand::class, Commands\ControllerMakeCommand::class, Commands\ChannelMakeCommand::class, Commands\DisableCommand::class, Commands\DumpCommand::class, Commands\EnableCommand::class, Commands\EventMakeCommand::class, Commands\FactoryMakeCommand::class, Commands\JobMakeCommand::class, Commands\ListenerMakeCommand::class, Commands\MailMakeCommand::class, Commands\MiddlewareMakeCommand::class, Commands\NotificationMakeCommand::class, Commands\ObserverMakeCommand::class, Commands\PolicyMakeCommand::class, Commands\ProviderMakeCommand::class, Commands\InstallCommand::class, Commands\LaravelModulesV6Migrator::class, Commands\ListCommand::class, Commands\ModuleDeleteCommand::class, Commands\ModuleMakeCommand::class, Commands\MigrateCommand::class, Commands\MigrateFreshCommand::class, Commands\MigrateRefreshCommand::class, Commands\MigrateResetCommand::class, Commands\MigrateRollbackCommand::class, Commands\MigrateStatusCommand::class, Commands\MigrationMakeCommand::class, Commands\ModelMakeCommand::class, Commands\ResourceMakeCommand::class, Commands\RequestMakeCommand::class, Commands\RuleMakeCommand::class, Commands\RouteProviderMakeCommand::class, Commands\PublishCommand::class, Commands\PublishConfigurationCommand::class, Commands\PublishMigrationCommand::class, Commands\PublishTranslationCommand::class, Commands\SeedCommand::class, Commands\SeedMakeCommand::class, Commands\SetupCommand::class, Commands\TestMakeCommand::class, Commands\UnUseCommand::class, Commands\UpdateCommand::class, Commands\UseCommand::class, ], /* |-------------------------------------------------------------------------- | Scan Path |-------------------------------------------------------------------------- | | Here you define which folder will be scanned. By default will scan vendor | directory. This is useful if you host the package in packagist website. | */ 'scan' => [ 'enabled' => false, 'paths' => [ base_path('vendor/*/*'), ], ], /* |-------------------------------------------------------------------------- | Composer File Template |-------------------------------------------------------------------------- | | Here is the config for composer.json file, generated by this package | */ 'composer' => [ 'vendor' => 'nwidart', 'author' => [ 'name' => 'Nicolas Widart', 'email' => 'n.widart@gmail.com', ], 'composer-output' => false, ], /* |-------------------------------------------------------------------------- | Caching |-------------------------------------------------------------------------- | | Here is the config for setting up caching feature. | */ 'cache' => [ 'enabled' => false, 'driver' => 'file', 'key' => 'laravel-modules', 'lifetime' => 60, ], /* |-------------------------------------------------------------------------- | Choose what laravel-modules will register as custom namespaces. | Setting one to false will require you to register that part | in your own Service Provider class. |-------------------------------------------------------------------------- */ 'register' => [ 'translations' => true, /** * load files on boot or register method * * Note: boot not compatible with asgardcms * * @example boot|register */ 'files' => 'register', ], /* |-------------------------------------------------------------------------- | Activators |-------------------------------------------------------------------------- | | You can define new types of activators here, file, database etc. The only | required parameter is 'class'. | The file activator will store the activation status in storage/installed_modules */ 'activators' => [ 'file' => [ 'class' => FileActivator::class, 'statuses-file' => base_path('modules_statuses.json'), 'cache-key' => 'activator.installed', 'cache-lifetime' => 604800, ], ], 'activator' => 'file', ]; PKZe9'laravel-modules/LICENSE.mdnu[# The MIT License (MIT) Copyright (c) 2014 Pingpong Labs Copyright (c) 2016 Nicolas Widart bvba > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal > in the Software without restriction, including without limitation the rights > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > copies of the Software, and to permit persons to whom the Software is > furnished to do so, subject to the following conditions: > > The above copyright notice and this permission notice shall be included in > all copies or substantial portions of the Software. > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > THE SOFTWARE. PKZ  laravel-modules/.editorconfignu[; This file is for unithyng the coding style for different editors and IDEs. root = true; [*] charset = utf_8 indent_size = 4 indent_style = space end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = falsePKZtxAUAUlaravel-modules/CHANGELOG.mdnu[# Changelog All Notable changes to `laravel-modules` will be documented in this file. ## Next ## 10.0.2 - 2023-09-18 ## Changed - reordered config commands and added missing observer command ## 10.0.1 - 2023-09-18 ## Added - [@JaberWiki](https://github.com/JaberWiki) Added Include an optional flag `subpath` for rolling back a module's specific migration file [#1626](https://github.com/nWidart/laravel-modules/pull/1626) - [@sergiy-petrov](https://github.com/sergiy-petrov) Added support for testing GitHub actions against PHP versions 8.2 and 8.3. [#1624](https://github.com/nWidart/laravel-modules/pull/1624) - [@hanieas](https://github.com/hanieas) Added make Observer command. [#1623](https://github.com/nWidart/laravel-modules/pull/1623) - [@alissn](https://github.com/alissn) Add phpdoc to Module facade class for IDE auto-completion. [#1589](https://github.com/nWidart/laravel-modules/pull/1589) - [@aryala7](https://github.com/aryala7) Add command to create broadcasting channel [#1599](https://github.com/nWidart/laravel-modules/pull/1599) ## Changed - [@Rattone](https://github.com/Rattone) Updated stubs for command from `name` to `signature` [#1625](https://github.com/nWidart/laravel-modules/pull/1625) - [@moeen-basra](https://github.com/moeen-basra) Remove the unused Factory import [#1596](https://github.com/nWidart/laravel-modules/pull/1596) - [@moeen-basra](https://github.com/moeen-basra) Replace the \Config::get with config function [#1596](https://github.com/nWidart/laravel-modules/pull/1596) - [@aryala7](https://github.com/aryala7) Changed disable module Command to accept array of modules instead of single module to disable [#1591](https://github.com/nWidart/laravel-modules/pull/1591) ## 10.0.0 - 2023-02-14 ### Changed - Minimum PHP version to 8.1 for supporting Laravel 10 - Laravel 10 version - Increased PHPUnit to 10.0 - Increased Mockery to 1.5 ## Updated - [@dev-karpenko](https://github.com/dev-karpenko) updated get attributes cache [#1526](https://github.com/nWidart/laravel-modules/pull/1526) ## 9.0.7 - 2022-11-17 ## Added - [@alissn](https://github.com/alissn) implement command check lang folder, and show missing files [#1496](https://github.com/nWidart/laravel-modules/pull/1496) - [@kmizzi](https://github.com/kmizzi) Use AsCommand in lieu of defaultName for ModelShowCommand [#1503](https://github.com/nWidart/laravel-modules/pull/1503) ## 9.0.6 - 2022-10-28 ## Added - [@wikigods](https://github.com/wikigods) added vite compatibility [#1455](https://github.com/nWidart/laravel-modules/pull/1455) - [@WMOH-DEV](https://github.com/WMOH-DEV) Adding migrate fresh command [#1483](https://github.com/nWidart/laravel-modules/pull/1483) ## 9.0.5 - 2022-08-31 ## Added - [@alissn](https://github.com/alissn) add command show model information [#1429](https://github.com/nWidart/laravel-modules/pull/1429) - [@JaberWiki](https://github.com/JaberWiki) add optional flag for seeder or request in model generator command [#1431](https://github.com/nWidart/laravel-modules/pull/1431) ## Changed - [@alissn](https://github.com/alissn) updated command style to new version of artisan [#1430](https://github.com/nWidart/laravel-modules/pull/1430) - [@ChauDucGiang](https://github.com/ChauDucGiang) updated Feature/cache driver [#1443](https://github.com/nWidart/laravel-modules/pull/1443) ### Fixed - [@ajayfroiden](https://github.com/alissn) fixed module:disable [#1438](https://github.com/nWidart/laravel-modules/pull/1438) - [@inovar-tecnologia](https://github.com/inovar-tecnologia) fixed DisableCommand.php[#1435](https://github.com/nWidart/laravel-modules/pull/1435) ## 9.0.4 - 2022-07-28 - 9.02 - 9.0.3 have been removed due to savere performance problems ## 9.0.1 - 2022-02-28 ### Added - Added option to publish stubs for modules `php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider" --tag="stubs"` ### Changed - [@iamine](https://github.com/iamine) Added Anonymous migration class as default like in Laravel 9.0 [#1363](https://github.com/nWidart/laravel-modules/pull/1363) ## 9.0 - 2022-02-10 ### Changed - Minimum PHP version to 8.0 for supporting Laravel 9 - Laravel 9 version - Increased PHPUnit to 9.5 - Increased Mockery to 1.4 - Fixed test replaced expectsEvents with event fakes ## 8.3 - 2022-02-10 ### Fixed - The ability to override commands via config file. - Incorrectly placed config key - Class name when special characters are used in the rule name - Fix error on anonymous migration ### Changed - Changed `View/Component` to `View/Components` - Updated test snapshots for the MakeCommand test snapshots - Command stub signature from `signature` to `name` - Revert PR1171 which causes tests to fail ### Added - Added commands make class component and make view component - Test against php 8.0 - Merge config in register method - Added optional controller flag to model generator command - Set module for make-controller command - Added tests for generating controller in model generator command - Added test for check if migration and controller flag are both present - Laravel mix v6 support ## 8.2 - 2020-11-11 ### Added - New `module:make-component` command to generate laravel components ### Fixed - Fixed bug: `Target class [Nwidart\Modules\Commands\] does not exist.` ## 8.1 - 2020-11-10 ### Added - Command management via configuration file - Laravel 8 Factories compatibility - New improved way to define controller types. `--web`, `--api` and `--plain` options. - New configuration option to make compose run in silent mode ### Changed - New generated commands now use the `$signature` property instead of `$name` - Fixed issue where `order` was used instead of `priority` ## 8.0 - 2020-10-03 ### Added - Laravel 8 support ### Updated - Update `ListenerMakeCommand` to properly use the `--events` option ## 7.2.0 - 2020-07-30 ### Added - Added return statements in artisan commands. Helpful to validate if something was successfully ran. (#1026) ### Changed - Update JsonResource namespace, using the new `Illuminate\Http\Resources\Json\JsonResource`. (#969) - Enable command returns the status code (#978) - Removing module service provider from composer.json stub (#996) - Fixed custom stub path issue. Replacing a hardcoded stub path. (#1016) - Controller return type changed to `Illuminate\Contracts\Support\Renderable`. (#1020) - Change bigIncrements method to id (#1029) - Adding force option for module:seed (#1030) ## 7.1.0 - 2020-04-14 ### Changed - `php artsian module:enable` (without any arguments) will enable all modules - `php artsian module:disable` (without any arguments) will disable all modules - Updating Laravel Mix version as well as cross-env. ## 7.0.0 - 2020-03-26 ### Added - Laravel 7.0 support ## 6.2.0 - 2019-11-12 ### Changed - Properly guessing the namespace from the path (in `GeneratorPath` class) - Fixing generation of resource file if the resource has been disabled to generate - Fix when using a custom service provider namespace, namespace is correctly referenced in module.json and compose.json - Fix when using custom service provider namespace, module path is correctly referenced in the `RouteServiceProvider` and `ModuleServiceProvider` - Fix when using a custom path for controllers in the controller stub ## 6.1.0 - 2019-11-01 ### Added - Added new `module:delete` command ### Changed - Add optional path parameter to `module_path` helper (PR#861) - The default path of the `module_statuses.json` file has been moved to the Application's base path. This is to improve its visibility and the fact that it can be committed by default. - Throw an exception when no proper activator class was configured ## 6.0.0 - 2019-09-19 ### Added - New File Activator feature. [PR #790](https://github.com/nWidart/laravel-modules/pull/790) from @ryssbowh This feature changes how modules are activated and de-activated. Currently module statuses are stored on disk, this features adds the possibility of storing this status information in a database. **Use the command `php artisan module:v6:migrate` to have old modules active status migrated to the new system.** ### Changed - Alternate way to define the namespace of modules in [PR #776](https://github.com/nWidart/laravel-modules/pull/776) by @daison12006013 This allows to have the content of the module under an `src/` folder for example. - **BREAKING** New way to handle active and inactive modules. Modules don't store their active status in their module.json file anymore, but in a file under the storage folder. Run `php artisan module:v6:migrate` to use the new system. - **BREAKING** Renamed method `enabled` to `isEnabled` in `\Nwidart\Modules\Module`. - **BREAKING** Renamed method `disabled` to `isDisabled` in `\Nwidart\Modules\Module`. - **BREAKING** Renamed method `enabled` to `isEnabled` in `\Nwidart\Modules\FileRepository`. - **BREAKING** Renamed method `disabled` to `isDisabled` in `\Nwidart\Modules\FileRepository`. - **BREAKING** Removed the `__get` magic method on the `\Nwidart\Modules\Module` class. Use `get()` or `json()->get()` instead. - The `module:make-listener` command now correctly uses the namespace configuration - The generated Factories now has type hints for the `\Illuminate\Database\Eloquent\Factory` class - Improved foreign key constraint generation - Exception handling in the `SeedCommand` has been improved ## 5.0.1 - 2019-05-11 ### Added - `artisan module:route-provider` has a `--force` option to overwrite existing file ### Changed - Fixing the `RouteServiceProvider` generation to properly use the `routes/web` and `routes/api` stubs - Replacing `@stop` with `@endsection` in the view stub file - `Module` class does not extend Laravel's Service Provider class anymore ## 5.0.0 - 2019-03-18 ### Added - Laravel 5.8 support ### Changed - Deprecated string and array methods have been replaced - Fixed caching not being cleared after disabling and enabling modules - Update Route Provider stub to not affect the root namespace of the URL generator (#727) ### Removed - **PHP 7.1 support** ## 4.1.0 - 2019-03-04 ### Changed - Updated to laravel mix 4 - Add `--api` argument to `module:make-controller` command - Seeding modules outside out `Modules` namespace ## 4.0.0 - 2018-09-30 ### Added - New way of handling routes by default using a RouteServiceProvider (instead of start.php) - Laravel 5.7 support ### Changed - Allow class resolution on short name and abstract - `module:seed` accepts a `--class` option ## 3.3.1 - 2018-07-13 ### Changed - Added the ability to set a sub-namespace to controllers `module:make-controller Api\\TestController` ## 3.3.0 - 2018-06-21 ### Changed - `module:update` command has now the possibility to update all modules at once - Fixing commented code for Laravel Mix ## 3.2.0 - 2018-04-16 ### Added - Added possibility to update all modules at once if any not specified (PR #523) ### Changed - Mix: Fix css relative urls by changing the route folder (PR #521) - Mix: Prevents every build from deleting previous Mix config file (PR #521) ## 3.1.0 - 2018-04-01 ### Added - Laravel mix configuration (https://nwidart.com/laravel-modules/v3/basic-usage/compiling-assets) ### Changed - Allow symlinks in module path - Returns the parameter `--class` to the `SeedCommand`. - Generate folders recursively - Removing link that has become a 404 - Fixed seed command exception typehint ### Removed - Removed the optimize command on the `module:make-migration` command ## 3.0.1 - 2018-02-16 ### Changed - Update publish commands to use the new API to get all enabled modules (PR #483 ) ## 3.0.0 - 2018-02-14 ## Added - Added support for laravel 5.6 - Using phpunit 7 ## Changed - **BC:** `Repository` class: renamed `enabled` to `allEnabled` - **BC:** `Repository` class: renamed `disabled` to `allDisabled` - **BC:** `Repository` class: renamed `active` to `enabled` - **BC:** `Repository` class: renamed `notActive` to `disabled` ## Removed - Dropped php 7.0 support - **BC:** `Module` class: Deprecated `active()` method, use `enabled()` - **BC:** `Module` class: Deprecated `notActive()` method, use `disabled()` - **BC:** `Repository` class: Deprecated `addPath()` method, use `addLocation()` - **BC:** `Repository` class: Deprecated `get()` method, use `find()` - **BC:** `Repository` class: Deprecated `getUsed()` method, use `getUsedNow()` ## 2.7.0 - 2018-01-13 ## Changed - Rename the `before` method to `boot` in the `RouterServiceProvider` stub file - Fixing caching issue if modules were loaded from a different directory - Fixing how modules are loaded from vendor directory (#423 #417) - Update to Mockery 1.0 - use default file stubs only if override does not exists - Fix non well formed numeric value in seed command ## 2.6.0 - 2017-11-07 ## Added - Ability to customise the destination folder & namespace of a generated class - Added `php artisan module:migrate-status` command - `config_path()` helper for Lumen - Added views tag to view config in ServiceProvider - added package auto discovery for laravel 5.5 in generated module `composer.json` ## Changed - Adding the ability to correctly load modules from multiple locations, together - Custom seeder path now also used in the `module:seed` command ## 2.5.1 - 2017-10-13 ## Changed - added config_path helper to helpers for Lumen support - updated readme on how to install laravel-modules in Lumen ## 2.5.0 - 2017-10-03 ## Changed - Making the path to migrations for `loadMigrationsFrom()` call dynamic based of configuration - Making the factory path dynamic for master service provider & make-factory command - Make the route file location dynamic in start.php based of `stubs.files.routes` - Making the route path dynamic on the route service provider based of `stubs.files.routes` - New structure in configuration to set which folders will be generated on `module:make` (old format still supported) - Setting new sensible defaults to what folders to generate by default. - Change the assets directory default location `resources/assets` ## 2.4.1 - 2017-09-27 ## Changed - Setting a default value for `modules.paths.modules` configuration key ## 2.4.0 - 2017-09-27 ## Added - New `module:make-resource` command to generate resource classes - New `module:make-test` command to generate test classes ## Changed - Improved error output of the `module:seed` command - Marking methods that served as proxies in `Module` and `Repository` classes as deprecated for next major - Fixed `module:make` and `module:make-provider` to generate the correct master service provider - Tests: tests are now using `spatie/phpunit-snapshot-assertions` to make sure the generated files have the correct content - Adding a sync option to the `module:make-job` command to make a synchronous job class - Changed `module:make-event` command to allow duck typed events (not type hinted event class) - Changed `module:make-listener` to allow a `--queued` option to make the event queueable - Changed `module:make-listener` command to not use the full class typehint when class was previous imported ## 2.3.0 - 2017-09-26 ## Added - Ability to ignore some folders to generate - Creating an module:unuse command to forget the previously saved module - New command to generate Policy classes - New command for creating factories - New command for creating rules - new `public_path` helper for Lumen ## Changed - Refactored class names that generate something to be fully consistent ## 2.2.1 - 2017-09-14 ## Changed - Fixed class namespace to `Repository` in `ContractsServiceProvider` ## 2.2.0 - 2017-09-14 ### Added - Lumen compatibility with new way to register providers ## 2.1.0 - 2017-09-10 ### Changed - Register module migrations - Fixed issue with `module:migrate-refresh` command - Improved module loading of their service providers. Using laravel caching system. Allowing usage of deferred providers. - Fixed path to module factories ## 2.0.0 - 2017-08-31 ### Added - Support Laravel 5.5 ## 1.27.2 - 2017-08-29 ### Changed - Allow migrate-refresh command to be run without module argument - Module name was added to the module enable and disable events ## 1.27.1 - 2017-07-31 ### Changed - Only run composer require on the module:update command if there's something to require - Fixing lumen support ## 1.27.0 - 2017-07-19 ### Added - Laravel Lumen support ### Changed - Update dev dependencies grumphp and phpcsfixer to latest versions - The `make:model` command with the `-m` flag to create the associated migration is now using a current migration file name ## 1.26.0 - 2017-07-06 ### Changed - Throw an exception if asset name structure was not correct when using `{!! Module::asset() !!}` - Create the module used file if non existent. Will provide for a better error message if module is omitted in console commands without a module:use. ## 1.25.1 - 2017-06-29 ### Changed - More flexibility to the `json()` method, while keeping the performance improvements. ## 1.25.0 - 2017-06-29 ### Changed - Improving performance by only instantiating Json class for the module.json file once - Added support for generic git hosts ## 1.24.0 - 2017-06-12 ### Changed - Using `resource_path` to register module views - Changed the method to load additional eloquent factory paths ## 1.23.0 - 2017-06-09 ## Added - A `--migration` flag to the `module:make-model` command to generate the migration file with a model - Factories are now also defined in the master service providers. This is used in the `module:make` command without the `--plain` flag, or using `module:make-provider` with the `--master` flag. - `module_path()` helper function. ### Changed - The default location of event listeners is now in `Listeners/`, from `Events/Handlers` ## 1.22.0 - 2017-05-22 ### Changed - Fixed the `--plain` on the `make:module` command, to not include a service provider in the `module.json` file as it's not generated. - Add command description to the `GenerateNotificationCommand`. ## 1.21.0 - 2017-05-10 ### Added - Added the `Macroable` trait to the `Module` class. ### Changed - The `collections` method now accepts an optional parameter to get modules by status, in a laravel collection. - Allow laravel `5.5.*` to be used. ## 1.20.0 - 2017-04-19 ### Changed - `module:update`: Copy over the scripts key to main composer.json file - Add a `--subpath` option to migrate command - `module:update`: Install / require all require & require-dev package at once, instead of multiple calls to composer require. - `module:publish-config` command now uses the namespace set up in the configuration file. ## 1.19.0 - 2017-03-16 ### Changed - `module:update` command now also takes the `require-dev` key into account - Making the `$migrations` parameter optional on `getLastBatchNumber()` ## 1.18.0 - 2017-03-13 ### Changed - The module list command (`module:list`) now returns the native module name ## 1.17.1 - 2017-03-02 ### Changed - Fixed issues with route file location in `start.php` ## 1.17.0 - 2017-02-27 ### Changed - Add checking for failure to parse module JSON ## 1.16.0 - 2017-01-24 ### Added - Support for Laravel 5.4 - Adding show method on resource controller - Added check for cached routes to not load them multiple times ## 1.15.0 - 2017-01-12 ### Added - Module requirements (PR #117) - Added `Macroable` trait to `Module` class (PR #116) ### Changed - Added missing import of the `Schema` facade on migration stubs - A default plain migration will be used if the name was not matched against a predefined structure (create, add, delete and drop) - Add tests for all the different migration structures above - Fix: respecting order in reverse migrations (PR #98) - Fix: `module:reset` and `module:migrate-rollback` didn't have `--database` option (PR #88) - Fix: `Module::asset()`, removed obsolete backslash. (PR #91) ## 1.14.0 - 2016-10-19 ### Added - `module:make-notification` command to generate a notification class ### Changed - Usage of the `lists()` method on the laravel collection has been removed in favor of `pluck()` - Modules can now overwrite the default migration and seed paths in the `module.json` file ## 0.13.1 - 2016-09-09 ### Changed - Generated emails are now generated in the `Emails` folder by default ## 0.13.0 - 2016-09-08 ### Changed - Ability to set default value on the config() method of a module. - Mail: Setting default value to config. Using that as the namespace. - Using PSR2 for generated stubs ## 0.12.0 - 2016-09-08 ### Added - Generation of Mailable classes ## 0.11.2 - 2016-08-29 ### Changed - Using stable version of laravelcollective/html (5.3) ## 0.11.1 - 2016-08-25 ### Changed - Using stable development of laravelcollective/html ## 0.11 - 2016-08-24 ### Added - Adding `module:make-job` command to generate a job class - Adding support for Laravel 5.3 ### Changed - Added force option to module:seed command ## 0.10 - 2016-08-10 ### Added - Experimental Laravel 5.3 support ### Changed - Make sure the class name has `Controller` appended to it as well. Previously only the file had it suffixed. ### Removed - Dependencies: `pingpong/support` and `pingpong/generators` ## 0.9 - 2016-07-30 ### Added - Adding a plain option to the generate controller command ### Changed - Generate controller command now generates all resource methods ## 0.8 - 2016-07-28 ### Fixed - Module generation namespace now works with `StudlyCase` ([Issue #14](https://github.com/nWidart/laravel-modules/issues/14)) - No module namespace fix (#13) ### Changed - Using new service provider stub for module generation too ## 0.1 - 2016-06-27 Initial release PKZ_ylaravel-modules/composer.jsonnu[PKZNoo1`laravel-modules/src/Traits/ModuleCommandTrait.phpnu[PKZ_d30laravel-modules/src/Traits/MigrationLoaderTrait.phpnu[PKZ͢773 laravel-modules/src/Traits/CanClearModulesCache.phpnu[PKZ Fkk+ laravel-modules/src/Migrations/Migrator.phpnu[PKZ{||**laravel-modules/src/Routing/Controller.phpnu[PKZdk8,laravel-modules/src/Exceptions/InvalidActivatorClass.phpnu[PKZ:3.laravel-modules/src/Exceptions/InvalidAssetPath.phpnu[PKZH"cc: 0laravel-modules/src/Exceptions/ModuleNotFoundException.phpnu[PKZ7 ee<0laravel-modules/src/Exceptions/FileAlreadyExistException.phpnu[PKZpfF,``71laravel-modules/src/Exceptions/InvalidJsonException.phpnu[PKZ9902laravel-modules/src/Activators/FileActivator.phpnu[PKZQm 'Flaravel-modules/src/Process/Updater.phpnu[PKZq*k((&7Plaravel-modules/src/Process/Runner.phpnu[PKZJ  )Rlaravel-modules/src/Process/Installer.phpnu[PKZʻ5llaravel-modules/src/Support/Migrations/NameParser.phpnu[PKZ}rHQ72{laravel-modules/src/Support/Migrations/SchemaParser.phpnu[PKZ41laravel-modules/src/Support/Config/GeneratorPath.phpnu[PKZ(A;!laravel-modules/src/Support/Config/GenerateConfigReader.phpnu[PKZv $slaravel-modules/src/Support/Stub.phpnu[PKZ(nKK,~laravel-modules/src/Generators/Generator.phpnu[PKZ//'f! ! 0%laravel-modules/src/Generators/FileGenerator.phpnu[PKZT332laravel-modules/src/Generators/ModuleGenerator.phpnu[PKZGr " "laravel-modules/src/Module.phpnu[PKZlaravel-modules/src/Json.phpnu[PKZ5gD 4laravel-modules/src/Commands/MigrateResetCommand.phpnu[PKZII0F&laravel-modules/src/Commands/MailMakeCommand.phpnu[PKZnA 2.laravel-modules/src/Commands/ModuleMakeCommand.phpnu[PKZGGff:9laravel-modules/src/Commands/PublishTranslationCommand.phpnu[PKZQ-Alaravel-modules/src/Commands/SetupCommand.phpnu[PKZ/E E /Hlaravel-modules/src/Commands/JobMakeCommand.phpnu[PKZ0% 1Slaravel-modules/src/Commands/GeneratorCommand.phpnu[PKZ23__2]laravel-modules/src/Commands/PolicyMakeCommand.phpnu[PKZ :flaravel-modules/src/Commands/ComponentClassMakeCommand.phpnu[PKZϑ 6rlaravel-modules/src/Commands/MigrateRefreshCommand.phpnu[PKZ1GG0|laravel-modules/src/Commands/RuleMakeCommand.phpnu[PKZЖ9 4laravel-modules/src/Commands/ObserverMakeCommand.phpnu[PKZiZZ6laravel-modules/src/Commands/ControllerMakeCommand.phpnu[PKZM+x;Q Q 0claravel-modules/src/Commands/TestMakeCommand.phpnu[PKZ\[v5laravel-modules/src/Commands/MigrationMakeCommand.phpnu[PKZ 8laravel-modules/src/Commands/PublishMigrationCommand.phpnu[PKZ⢿4vlaravel-modules/src/Commands/ModuleDeleteCommand.phpnu[PKZ}ll3wlaravel-modules/src/Commands/RequestMakeCommand.phpnu[PKZђ/Flaravel-modules/src/Commands/InstallCommand.phpnu[PKZn?}}+Klaravel-modules/src/Commands/UseCommand.phpnu[PKZ%Y[n n 3#laravel-modules/src/Commands/CommandMakeCommand.phpnu[PKZ. . 6laravel-modules/src/Commands/MiddlewareMakeCommand.phpnu[PKZU+ + 4laravel-modules/src/Commands/ProviderMakeCommand.phpnu[PKZfP P 9laravel-modules/src/Commands/RouteProviderMakeCommand.phpnu[PKZ*JkLL1laravel-modules/src/Commands/ModelShowCommand.phpnu[PKZ"5}laravel-modules/src/Commands/MigrateStatusCommand.phpnu[PKZxx9"laravel-modules/src/Commands/LaravelModulesV6Migrator.phpnu[PKZ:\ S S 4'laravel-modules/src/Commands/ResourceMakeCommand.phpnu[PKZ$9x2laravel-modules/src/Commands/ComponentViewMakeCommand.phpnu[PKZAN19laravel-modules/src/Commands/ModelMakeCommand.phpnu[PKZ q,Rlaravel-modules/src/Commands/SeedCommand.phpnu[PKZPҌ 4;nlaravel-modules/src/Commands/ListenerMakeCommand.phpnu[PKZUCQQ<+|laravel-modules/src/Commands/PublishConfigurationCommand.phpnu[PKZH2;;.laravel-modules/src/Commands/UpdateCommand.phpnu[PKZn]U  3laravel-modules/src/Commands/FactoryMakeCommand.phpnu[PKZL&,laravel-modules/src/Commands/DumpCommand.phpnu[PKZQߨ1laravel-modules/src/Commands/EventMakeCommand.phpnu[PKZ(L 7laravel-modules/src/Commands/MigrateRollbackCommand.phpnu[PKZW  /laravel-modules/src/Commands/MigrateCommand.phpnu[PKZ؟8Vlaravel-modules/src/Commands/NotificationMakeCommand.phpnu[PKZ@ Y:--.claravel-modules/src/Commands/EnableCommand.phpnu[PKZ<9,laravel-modules/src/Commands/ListCommand.phpnu[PKZ`AA/'laravel-modules/src/Commands/PublishCommand.phpnu[PKZP=Hxx4laravel-modules/src/Commands/MigrateFreshCommand.phpnu[PKZkxx-laravel-modules/src/Commands/UnUseCommand.phpnu[PKZq/xlaravel-modules/src/Commands/DisableCommand.phpnu[PKZ7laravel-modules/src/Commands/stubs/assets/sass/app.stubnu[PKZ5Qlaravel-modules/src/Commands/stubs/assets/js/app.stubnu[PKZFZdd2laravel-modules/src/Commands/stubs/middleware.stubnu[PKZ]A@@.|laravel-modules/src/Commands/stubs/seeder.stubnu[PKZ 23laravel-modules/src/Commands/stubs/views/index.stubnu[PKZ5OO4?laravel-modules/src/Commands/stubs/views/master.stubnu[PKZ8UU0laravel-modules/src/Commands/stubs/resource.stubnu[PKZm'څ,laravel-modules/src/Commands/stubs/rule.stubnu[PKZWh0laravel-modules/src/Commands/stubs/provider.stubnu[PKZp\kk-~laravel-modules/src/Commands/stubs/model.stubnu[PKZh~""6Flaravel-modules/src/Commands/stubs/component-view.stubnu[PKZD=-laravel-modules/src/Commands/stubs/event.stubnu[PKZM兊+laravel-modules/src/Commands/stubs/job.stubnu[PKZ0 laravel-modules/src/Commands/stubs/observer.stubnu[PKZ!1n0\ laravel-modules/src/Commands/stubs/composer.stubnu[PKZ,p,Xlaravel-modules/src/Commands/stubs/vite.stubnu[PKZlaravel-modules/src/Commands/stubs/controller-api.stubnu[PKZ9T2Blaravel-modules/src/Commands/stubs/routes/web.stubnu[PKZ;HT2Dlaravel-modules/src/Commands/stubs/routes/api.stubnu[PKZ67PGlaravel-modules/src/Commands/stubs/migration/plain.stubnu[PKZ&<<5YIlaravel-modules/src/Commands/stubs/migration/add.stubnu[PKZ&<<8Klaravel-modules/src/Commands/stubs/migration/delete.stubnu[PKZ|&UU6Nlaravel-modules/src/Commands/stubs/migration/drop.stubnu[PKZ FF8YQlaravel-modules/src/Commands/stubs/migration/create.stubnu[PKZ#g,Tlaravel-modules/src/Commands/stubs/mail.stubnu[PKZK 9}Vlaravel-modules/src/Commands/stubs/scaffold/provider.stubnu[PKZ"(:117alaravel-modules/src/Commands/stubs/scaffold/config.stubnu[PKZ0 6blaravel-modules/src/Commands/stubs/route-provider.stubnu[PKZ`  4hlaravel-modules/src/Commands/stubs/policy.plain.stubnu[PKZ4  7mjlaravel-modules/src/Commands/stubs/listener-queued.stubnu[PKZmCC1llaravel-modules/src/Commands/CheckLangCommand.phpnu[PKZaG  0laravel-modules/src/Commands/SeedMakeCommand.phpnu[PKZ\5rr3laravel-modules/src/Commands/ChannelMakeCommand.phpnu[PKZaN/5laravel-modules/src/Publishing/MigrationPublisher.phpnu[PKZM,9laravel-modules/src/Publishing/Publisher.phpnu[PKZXل0dlaravel-modules/src/Publishing/LangPublisher.phpnu[PKZ@9x1laravel-modules/src/Publishing/AssetPublisher.phpnu[PKZ<&冴laravel-modules/src/helpers.phpnu[PKZn[|jUU.laravel-modules/src/ModulesServiceProvider.phpnu[PKZiUBB&laravel-modules/src/Facades/Module.phpnu[PKZ`5Hlaravel-modules/src/LaravelModulesServiceProvider.phpnu[PKZ&v찤:laravel-modules/src/Providers/ContractsServiceProvider.phpnu[PKZLc^:laravel-modules/src/Providers/BootstrapServiceProvider.phpnu[PKZu 8laravel-modules/src/Providers/ConsoleServiceProvider.phpnu[PKZ!;;"laravel-modules/src/Collection.phpnu[PKZ$T@31laravel-modules/src/Lumen/LumenFileRepository.phpnu[PKZ𢶡${laravel-modules/src/Lumen/Module.phpnu[PKZX>3laravel-modules/src/LumenModulesServiceProvider.phpnu[PKZk&[3[3&laravel-modules/src/FileRepository.phpnu[PKZQw4P laravel-modules/src/Contracts/ActivatorInterface.phpnu[PKZPW62%laravel-modules/src/Contracts/RunableInterface.phpnu[PKZÓw w 5&laravel-modules/src/Contracts/RepositoryInterface.phpnu[PKZ-p̳43laravel-modules/src/Contracts/PublisherInterface.phpnu[PKZڕqq&4laravel-modules/src/Laravel/Module.phpnu[PKZ<)f  5v:laravel-modules/src/Laravel/LaravelFileRepository.phpnu[PKZgjj&;laravel-modules/.php-cs-fixer.dist.phpnu[PKZ(5