diff --git a/src/app/Console/Commands/Scalpel/Wallet/SettingsCommand.php b/src/app/Console/Commands/Scalpel/Wallet/SettingsCommand.php new file mode 100644 index 00000000..47ca881a --- /dev/null +++ b/src/app/Console/Commands/Scalpel/Wallet/SettingsCommand.php @@ -0,0 +1,14 @@ +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/ObjectCreateCommand.php b/src/app/Console/ObjectCreateCommand.php index 5cc0a1f8..81ef536d 100644 --- a/src/app/Console/ObjectCreateCommand.php +++ b/src/app/Console/ObjectCreateCommand.php @@ -1,66 +1,67 @@ description = "Create a {$this->objectName}"; $this->signature = sprintf( "%s%s:create", $this->commandPrefix ? $this->commandPrefix . ":" : "", $this->objectName ); $class = new $this->objectClass(); foreach ($class->getFillable() as $fillable) { $this->signature .= " {--{$fillable}=}"; } parent::__construct(); } public function getProperties() { if (!empty($this->properties)) { return $this->properties; } $class = new $this->objectClass(); $this->properties = []; foreach ($class->getFillable() as $fillable) { $this->properties[$fillable] = $this->option($fillable); } return $this->properties; } /** * Execute the console command. * * @return mixed */ public function handle() { $this->getProperties(); $class = new $this->objectClass(); $object = $this->objectClass::create($this->properties); if ($object) { + $this->cacheRefresh($object); $this->info($object->{$class->getKeyName()}); } else { $this->error("Object could not be created."); } return $object; } } diff --git a/src/app/Console/ObjectUpdateCommand.php b/src/app/Console/ObjectUpdateCommand.php index f8245bd8..3fb09701 100644 --- a/src/app/Console/ObjectUpdateCommand.php +++ b/src/app/Console/ObjectUpdateCommand.php @@ -1,96 +1,98 @@ description = "Update a {$this->objectName}"; $this->signature = sprintf( "%s%s:update {%s}", $this->commandPrefix ? $this->commandPrefix . ":" : "", $this->objectName, $this->objectName ); $class = new $this->objectClass(); try { foreach (Schema::getColumnListing($class->getTable()) as $column) { if ($column == "id") { continue; } $this->signature .= " {--{$column}=}"; } } catch (\Exception $e) { \Log::error("Could not extract options: {$e->getMessage()}"); } $classes = class_uses_recursive($this->objectClass); if (in_array(SoftDeletes::class, $classes)) { $this->signature .= " {--with-deleted : Include deleted {$this->objectName}s}"; } parent::__construct(); } public function getProperties() { if (!empty($this->properties)) { return $this->properties; } $class = new $this->objectClass(); $this->properties = []; foreach (Schema::getColumnListing($class->getTable()) as $column) { if ($column == "id") { continue; } if (($value = $this->option($column)) !== null) { $this->properties[$column] = $value; } } return $this->properties; } /** * Execute the console command. * * @return mixed */ public function handle() { $argument = $this->argument($this->objectName); $object = $this->getObject($this->objectClass, $argument, $this->objectTitle); if (!$object) { $this->error("No such {$this->objectName} {$argument}"); return 1; } foreach ($this->getProperties() as $property => $value) { if ($property == "deleted_at" && $value == "null") { $value = null; } $object->{$property} = $value; } $object->timestamps = false; $object->save(['timestamps' => false]); + + $this->cacheRefresh($object); } }