Skip to content

Commit

Permalink
Merge pull request #26 from vicgonvt/feature_namespace_custom
Browse files Browse the repository at this point in the history
Allow for custom namespacing
  • Loading branch information
vicgonvt authored Mar 18, 2020
2 parents 5759629 + af513de commit 449dafc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class Updater
*/
private $disk;

/**
* @var string
*/
private $baseNamespace = '\\App\\';

/**
* Get files in sync directory.
*
Expand All @@ -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.
*
Expand Down Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 449dafc

Please sign in to comment.