Merge pull request #26 from vicgonvt/feature_namespace_custom

Allow for custom namespacing
This commit is contained in:
Victor Gonzalez
2020-03-18 09:01:02 -04:00
committed by GitHub

View File

@@ -34,6 +34,11 @@ class Updater
*/ */
private $disk; private $disk;
/**
* @var string
*/
private $baseNamespace = '\\App\\';
/** /**
* Get files in sync directory. * Get files in sync directory.
* *
@@ -54,6 +59,16 @@ class Updater
$this->files = $this->getFiles($this->directory, $model); $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. * Execute syncModel for each file.
* *
@@ -232,7 +247,7 @@ class Updater
*/ */
protected function getModel(string $name) protected function getModel(string $name)
{ {
return '\\App\\'.Str::studly(pathinfo($name, PATHINFO_FILENAME)); return $this->baseNamespace.Str::studly(pathinfo($name, PATHINFO_FILENAME));
} }
/** /**