mirror of
https://github.com/nullthoughts/laravel-data-sync.git
synced 2026-02-12 09:52:18 +00:00
Merge pull request #26 from vicgonvt/feature_namespace_custom
Allow for custom namespacing
This commit is contained in:
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user