diff --git a/src/app/Console/Commands/User/AliasesCommand.php b/src/app/Console/Commands/User/AliasesCommand.php new file mode 100644 index 00000000..aa240f98 --- /dev/null +++ b/src/app/Console/Commands/User/AliasesCommand.php @@ -0,0 +1,41 @@ +getUser($this->argument('user')); + + if (!$user) { + $this->error("User not found."); + return 1; + } + + foreach ($user->aliases as $alias) { + $this->info("{$alias->alias}"); + } + } +} diff --git a/src/app/Console/Commands/UserAliasesCommand.php b/src/app/Console/Commands/UserAliasesCommand.php new file mode 100644 index 00000000..a19f5cde --- /dev/null +++ b/src/app/Console/Commands/UserAliasesCommand.php @@ -0,0 +1,13 @@ + geese). + * + * @var string + */ + protected $objectNamePlural; + /** * A column name other than the primary key can be used to identify an object, such as 'email' for users, * 'namespace' for domains, and 'title' for SKUs. * * @var string */ protected $objectTitle; /** * Placeholder for column name attributes for objects, from which command-line switches and attribute names can be * generated. * * @var array */ protected $properties; - /** * List of cache keys to refresh after updating/creating an object * * @var array */ protected $cacheKeys = []; /** * Reset the cache for specified object using defined cacheKeys. * * @param object $object The object that was updated/created */ protected function cacheRefresh($object): void { foreach ($this->cacheKeys as $cacheKey) { foreach ($object->toArray() as $propKey => $propValue) { if (!is_object($propValue)) { $cacheKey = str_replace('%' . $propKey . '%', $propValue, $cacheKey); } } Cache::forget($cacheKey); } } } diff --git a/src/app/Console/ObjectListCommand.php b/src/app/Console/ObjectListCommand.php index 21d13d8a..8b02a86e 100644 --- a/src/app/Console/ObjectListCommand.php +++ b/src/app/Console/ObjectListCommand.php @@ -1,56 +1,61 @@ description = "List {$this->objectName}s"; + $this->description = "List all {$this->objectName} objects"; $this->signature = $this->commandPrefix ? $this->commandPrefix . ":" : ""; - $this->signature .= "{$this->objectName}s"; + + if (!empty($this->objectNamePlural)) { + $this->signature .= "{$this->objectNamePlural}"; + } else { + $this->signature .= "{$this->objectName}s"; + } $classes = class_uses_recursive($this->objectClass); if (in_array(SoftDeletes::class, $classes)) { $this->signature .= " {--with-deleted : Include deleted {$this->objectName}s}"; } $this->signature .= " {--attr=* : Attributes other than the primary unique key to include}"; parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { $classes = class_uses_recursive($this->objectClass); if (in_array(SoftDeletes::class, $classes) && $this->option('with-deleted')) { $objects = $this->objectClass::withTrashed(); } else { $objects = new $this->objectClass(); } $objects->each( function ($object) { if ($object->deleted_at) { $this->info("{$this->toString($object)} (deleted at {$object->deleted_at}"); } else { $this->info("{$this->toString($object)}"); } } ); } }