3

I'm trying to build a small application on Laravel with modular approach, I am having a controller method which seeds the database as per the module/plugin name:

I have something like this:

Artisan::call('db:seed --class=Nitseditor\\Plugins\\'.$pluginName.'\\Databases\\seeds\\InstallSeeder');

Whenever I am calling this I am getting this error in my console.

Class NitseditorPluginsConfidenceDatabasesseedsInstallSeeder does not exist

I don't know why it remove \ and concatenate the strings.

How can I achieve this?

7
  • 1
    HOw did you create the seeder? have you tried composer dump-autoload? Commented May 2, 2019 at 14:17
  • @ggdx I already did composer dump-autoload. I created the seeder manually as it belongs to one of the modules in my application. Commented May 2, 2019 at 14:19
  • Try "db:seed --class=Nitseditor\Plugins\$pluginName\Databases\seeds\InstallSeeder" (quotes, not apostrophies) Commented May 2, 2019 at 14:20
  • Try --class="Nitseditor\Plugins\XXX\Databases..." instead. Commented May 2, 2019 at 14:20
  • @KFoobar It will give Too many arguments, expected arguments "command". Commented May 2, 2019 at 14:22

2 Answers 2

4

You can do:

$fullClassName = "Nitseditor\\Plugins\\${pluginName}\\Databases\\seeds\\InstallSeeder";

Artisan::call("db:seed", ['--class' => $class]);
Sign up to request clarification or add additional context in comments.

Comments

0

in my case when i have some module in subfolders

then want to run one of the Seeders directly without running other seeders

php artisan db:seed --class=WM\Common\Seeder\SmsStatusSeeder  

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.