ScaffoldModel
extends AbstractScaffoldCommand
in package
This command will create all the needed files for the default model used in the Athomos\Bennu system. It's available only the local environment
You should provide the ModuleName and the ClassName strings. ModuleName can contain backslashes to divide code into module. Bear in mind that you should use two backslashes in the console command
Examples: artisan bennu:scaffold-model artisan bennu:scaffold-model MyModule artisan bennu:scaffold-model MyModule MyClass artisan bennu:scaffold-model MyModule\MySubModule MyClass
Refer to the extended class for more information
Table of Contents
- $basePath : string
- Where files will be placed after replacements are done
- $description : string
- Command description
- $files : Filesystem
- The Laravel Filesystem class, used to read and write files
- $searchStrings : array<string|int, mixed>
- The array of the replacements to be done, in the format search => replace
- $signature : string
- Command signature, module and class are optional as they are cheched in the populateSearchString function. If they are not provided as arguments they will be asked to the user.
- $silent : bool
- Suppress all info,error,warn and printWelcome output messages use `$this->line` instead to force writing output in silent mode
- $stubFiles : array<string|int, mixed>
- The list of stub files to be elaborated
- $stubFolder : string
- Where the stubs are located
- __construct() : mixed
- Class constructor.
- call() : int
- Call another console command.
- error() : void
- Print an <error>$string</error> message
- handle() : void
- Handles the command.
- info() : void
- Print an <info>$string</info> message
- warn() : void
- Print an <error>$string</error> message
- printWelcome() : bool
- Prints a Welcome message
- populateSearchStrings() : void
- This function will populate the search strings.
Properties
$basePath
Where files will be placed after replacements are done
protected
string
$basePath
$description
Command description
protected
string
$description
= "This command will scaffold all needed files for a common bennu Model instance"
$files
The Laravel Filesystem class, used to read and write files
protected
Filesystem
$files
$searchStrings
The array of the replacements to be done, in the format search => replace
protected
array<string|int, mixed>
$searchStrings
= []
$signature
Command signature, module and class are optional as they are cheched in the populateSearchString function. If they are not provided as arguments they will be asked to the user.
protected
string
$signature
= "bennu:scaffold-model {module?} {class?} {--Y|yes}"
$silent
Suppress all info,error,warn and printWelcome output messages use `$this->line` instead to force writing output in silent mode
protected
bool
$silent
= false
$stubFiles
The list of stub files to be elaborated
protected
array<string|int, mixed>
$stubFiles
= ['database/migrations/snake_module_name/migration_datetime_create_snake_class_name_table.php', 'src/Modules/ModuleName/Enums/ClassNameStatus.php', 'src/Modules/ModuleName/Events/ClassName/ClassNameCreated.php', 'src/Modules/ModuleName/Events/ClassName/ClassNameDeleted.php', 'src/Modules/ModuleName/Events/ClassName/ClassNameUpdated.php', 'src/Modules/ModuleName/Http/Controllers/Api/ClassNameController.php', 'src/Modules/ModuleName/Http/Resources/ClassNameResource.php', 'src/Modules/ModuleName/Http/Resources/ClassNameResourceCollection.php', 'src/Modules/ModuleName/Jobs/ClassName/ProcessClassNameCreated.php', 'src/Modules/ModuleName/Jobs/ClassName/ProcessClassNameDeleted.php', 'src/Modules/ModuleName/Jobs/ClassName/ProcessClassNameUpdated.php', 'src/Modules/ModuleName/Listeners/ClassNameEventSubscriber.php', 'src/Modules/ModuleName/Models/ClassName.php', 'src/Modules/ModuleName/Policies/ClassNamePolicy.php', 'src/Modules/ModuleName/Factories/ClassNameFactory.php']
$stubFolder
Where the stubs are located
protected
string
$stubFolder
Methods
__construct()
Class constructor.
public
__construct(Filesystem $files) : mixed
It will build basePath and stubFolder variables and call the parent constructor
Parameters
- $files : Filesystem
Return values
mixed —call()
Call another console command.
public
call( $command[, array<string|int, mixed> $arguments = [] ]) : int
Parameters
Return values
int —error()
Print an <error>$string</error> message
public
error( $string[, $verbosity = null ]) : void
Parameters
Return values
void —handle()
Handles the command.
public
handle() : void
- Print welcome
- Get the search string
- Ask the parent to handle the command
Tags
Return values
void —info()
Print an <info>$string</info> message
public
info( $string[, $verbosity = null ]) : void
Parameters
Return values
void —warn()
Print an <error>$string</error> message
public
warn( $string[, $verbosity = null ]) : void
Parameters
Return values
void —printWelcome()
Prints a Welcome message
protected
printWelcome([string|null $message = null ][, bool $assumeYes = false ]) : bool
Parameters
- $message : string|null = null
- $assumeYes : bool = false
Return values
bool —populateSearchStrings()
This function will populate the search strings.
private
populateSearchStrings() : void
It will first check if module and class are provided, otherwise the two variables are asked to the user