From af513debeca9ba36d8b8e51932aae6eba1a4dbed Mon Sep 17 00:00:00 2001 From: Victor Gonzalex Date: Wed, 18 Mar 2020 08:50:45 -0400 Subject: [PATCH] allow for custom namespacing --- src/Updater.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Updater.php b/src/Updater.php index 63c6d22..a8188f3 100644 --- a/src/Updater.php +++ b/src/Updater.php @@ -34,6 +34,11 @@ class Updater */ private $disk; + /** + * @var string + */ + private $baseNamespace = '\\App\\'; + /** * Get files in sync directory. * @@ -54,6 +59,16 @@ public function __construct($path = null, $model = null, $remote = false, $disk $this->files = $this->getFiles($this->directory, $model); } + /** + * Override the default namespace for the class. + * + * @param $namespace + */ + public function setNamespace($namespace) + { + $this->baseNamespace = $namespace; + } + /** * Execute syncModel for each file. * @@ -232,7 +247,7 @@ protected function getValues(stdClass $record) */ protected function getModel(string $name) { - return '\\App\\'.Str::studly(pathinfo($name, PATHINFO_FILENAME)); + return $this->baseNamespace.Str::studly(pathinfo($name, PATHINFO_FILENAME)); } /**