Welcome Guest, Not a member yet? Register   Sign In
Run seed command in module
#1

I have create an Admin module, to add an Admin user into the db I created a seed file into the Admin\Database\Seeds path, below the code of the seeder
Code:
namespace Admin\Database\Seeds;

use CodeIgniter\Database\Seeder;
use CodeIgniter\Shield\Entities\User;
use App\Models\UserModel;

class AddAdminAccount extends Seeder
{
    public function run()
    {
        $user = new User([
            'email' => '[email protected]',
            'password' => 'secret',
            'firstname' => 'Admin',
            'lastname' => 'Strator',
        ]);

        $model = new UserModel;

        $model->save($user);

        $user = $model->findById($model->getInsertID());

        $user->activate();

        $user->addGroup('user', 'admin');
    }
}

The issue arises when I run the php spark dbConfusedeed NameFile command...I got the following error, since it seems that the command looks for the seeder file into the main app folder.
[InvalidArgumentException]
The specified seeder is not a valid file: D:\project\app\Database/Seeds/AddAdminAccount
I'm sure that could be an option to set spark db command to run in Admin module namespace...but I wasn't able to find it in CI documentation...am I wrong? 
Is it possible to run seed file in Admin module?
Thanks a lot for your feedback
Reply


Messages In This Thread
Run seed command in module - by Vespa - 01-05-2025, 07:47 AM
RE: Run seed command in module - by InsiteFX - 01-05-2025, 11:17 PM
RE: Run seed command in module - by Vespa - 01-06-2025, 01:15 AM
RE: Run seed command in module - by InsiteFX - 01-06-2025, 03:24 AM
RE: Run seed command in module - by Vespa - 01-06-2025, 06:22 AM
RE: Run seed command in module - by InsiteFX - 01-06-2025, 10:44 PM
RE: Run seed command in module - by InsiteFX - 01-07-2025, 10:41 PM
RE: Run seed command in module - by InsiteFX - 01-07-2025, 11:49 PM
RE: Run seed command in module - by InsiteFX - 01-08-2025, 11:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB