From 16a4297992a3a75ee46ac08f7a3752888fe1e5ec Mon Sep 17 00:00:00 2001 From: Rob Porter Date: Thu, 1 Apr 2021 15:55:14 -0400 Subject: [PATCH] Allowing Methods to be set in ModelHooks --- src/Console/ModelsCommand.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 8dcbb23..f9cc80c 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -749,7 +749,7 @@ class ModelsCommand extends Command } } - protected function setMethod($name, $type = '', $arguments = [], $comment = '') + public function setMethod($name, $type = '', $arguments = [], $comment = '') { $methods = array_change_key_case($this->methods, CASE_LOWER); @@ -761,6 +761,16 @@ class ModelsCommand extends Command } } + public function unsetMethod($name) { + unset($this->methods[strtolower($name)]); + } + + public function getMethodType(Model $model, string $classType) { + $modelName = $this->getClassNameInDestinationFile($model, get_class($model)); + $builder = $this->getClassNameInDestinationFile($model, $classType); + return $builder . '|' . $modelName; + } + /** * @param string $class * @return string