-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The MakeSettingsClass command speeds up the process #126
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\GeneratorCommand; | ||
|
||
|
||
class MakeSettingsClass extends GeneratorCommand | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'make:setting {name : Setting Class name} {--group= : The group name}'; | ||
|
||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
|
||
protected $name = 'make:setting'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new Settings Class'; | ||
|
||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'Setting Class'; | ||
|
||
protected function getStub() | ||
{ | ||
return __DIR__.'/stubs/settingClass.stub'; // todo: add stubs to package! | ||
egyjs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove newline here |
||
} | ||
|
||
protected function buildClass($name): array|string | ||
{ | ||
$class = parent::buildClass($name); // todo: uncomment after stubs added to package! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove comment here |
||
|
||
if ($this->option('group')) { | ||
$class = str_replace(['DummyView','{{ group }}'], $this->option('group'), $class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the use of Could we dynamically deduce |
||
} | ||
|
||
return $class; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add newline |
||
protected function getDefaultNamespace($rootNamespace): string | ||
{ | ||
return $rootNamespace.'\Settings'; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove newline |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Spatie\LaravelSettings\Settings; | ||
|
||
class {{ class }} extends Settings | ||
{ | ||
/** | ||
* The app name. | ||
* | ||
* @return string | ||
*/ | ||
// protected $appName = 'Laravel Settings'; | ||
Comment on lines
+9
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not add this to an empty Settings class |
||
|
||
|
||
public static function group(): string | ||
{ | ||
return '{{ group }}'; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove newline