diff --git a/src/Commands/ContentMakeCommand.php b/src/Commands/ContentMakeCommand.php new file mode 100644 index 0000000..bee702e --- /dev/null +++ b/src/Commands/ContentMakeCommand.php @@ -0,0 +1,60 @@ +confirm('Would you like to use App\\Models\\Content as the name space for all generated content?')) { + File::makeDirectory(app_path('Models/Content')); + } + + parent::handle(); + } + + protected function getStub() + { + return $this->resolveStubPath('/stubs/content.php.stub'); + } + + /** + * Resolve the fully-qualified path to the stub. + * + * @param string $stub + * @return string + */ + protected function resolveStubPath($stub) + { + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) + ? $customPath + : __DIR__.$stub; + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return is_dir(app_path('Models/Content')) ? $rootNamespace.'\\Models\\Content' : $rootNamespace.'\\Models'; + } +} diff --git a/src/Commands/stubs/content.php.stub b/src/Commands/stubs/content.php.stub new file mode 100644 index 0000000..f33e71b --- /dev/null +++ b/src/Commands/stubs/content.php.stub @@ -0,0 +1,17 @@ +name('contentable') + ->hasCommand(ContentMakeCommand::class) ->hasConfigFile() ->hasMigrations([ 'create_contents_table', diff --git a/src/Models/Module.php b/src/Models/Module.php new file mode 100644 index 0000000..ee97261 --- /dev/null +++ b/src/Models/Module.php @@ -0,0 +1,13 @@ +