Skip to content

Bug: module:seed is not working with --class options provided #419

@mufeedbinismail

Description

@mufeedbinismail

When using the module:seed command with the --class options provided it is not honoring the --class option. Instead it is checking for the existance of the default path {ModuleName}DatabaseSeeder and the non existing class entierly stops the seeding process.

/**  taken from src/Console/Commands/ModuleSeedCommand.php  97:104 **/

$fullPath = $namespacePath.'\\'.$module['basename'].'\Database\Seeds\\'.$rootSeeder;  
/**
* In My Case 
*     App\Modules\{ModuleName}\Database\Seeds\{ModuleName}DatabaseSeeder 
*/
if (class_exists($fullPath)) {
    if ($this->option('class')) {
        $params['--class'] = $this->option('class');
    } else {
        $params['--class'] = $fullPath;
    }
.
.
.

This may help a little bit to understand what I am saying

$defaultClassPath = $namespacePath.'\\'.$module['basename'].'\Database\Seeds\\'.$rootSeeder; 
$optionalClassPath = $this->option('class');
$fullPath = $optionalClassPath ? $optionalClassPath : $defaultClassPath;

if(class_exists($fullpath)){
     $params['--class'] = $fullPath;
.
.
.

PS: I renamed the class as a dirty fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions