-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vendor publish as well as register make:fm-model command
- Loading branch information
Showing
4 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace GearboxSolutions\EloquentFileMaker\Commands; | ||
|
||
use Illuminate\Foundation\Console\ModelMakeCommand as LaravelModelMakeCommand; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
class FMModelMakeCommand extends LaravelModelMakeCommand | ||
{ | ||
protected $name = 'make:model'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new Eloquent FileMaker model class'; | ||
|
||
public function handle() | ||
{ | ||
parent::handle(); | ||
|
||
$this->input->setOption('filemaker', true); | ||
} | ||
|
||
public function getStub() | ||
{ | ||
$stub = parent::getStub(); | ||
|
||
if ($this->option('filemaker')) { | ||
if ($this->option('pivot') || $this->option('morph-pivot')) { | ||
throw new \RuntimeException('This model type is not yet supported by Eloquent FileMaker.'); | ||
} | ||
|
||
$stub = $this->resolveFMStubPath('/stubs/fm.model.stub'); | ||
} | ||
|
||
return $stub; | ||
} | ||
|
||
/** | ||
* Resolve the fully-qualified path to the stub. | ||
* | ||
* @param string $stub | ||
* @return string | ||
*/ | ||
protected function resolveFMStubPath($stub) | ||
{ | ||
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) | ||
? $customPath | ||
: __DIR__ . $stub; | ||
} | ||
|
||
protected function getOptions() | ||
{ | ||
return array_merge(parent::getOptions(), [ | ||
['filemaker', null, InputOption::VALUE_NONE, 'Use the FileMaker stub instead of base model stub'], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use GearboxSolutions\EloquentFileMaker\Database\Eloquent\FMModel; | ||
|
||
class {{ class }} extends FMModel | ||
{ | ||
use HasFactory; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters