I am working on Laravel^9.19" project with php^8.1, I created a Modules folder and then I created a migration files inside, my structure is like this :
--app
--Modules
----user
------Database
--------Migrations
----------2023_07_19_220540_create_users_table.php
and inside my AppServiceProvider :
public function register()
{
//
$this->loadMigrationsFrom(base_path('Modules/UserManagement/Database/Migrations'));
}
and inside my composer.json
"autoload": {
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/",
}
},
the problem is when I am trying to execute php artisan migrate
it gave me nothing to migrate because it is not scanning any folder other than app/database
I search online so much but I couldn't find a solution, kindly advice with the solution in this case
To run migrations for tables inside modules in Laravel, you can follow these steps: Create a new migration for the module table using the command php artisan make:migration create_module_table --create=module. Replace "module" with the name of your module.
e.g. php artisan migrate --path=modules/ModuleName/database/migrations
In the migration file, define the schema for the module table using the Schema facade. For example, to create a table with "id" and "name" columns, you can use the following code:
Note: If you're using a modular structure in Laravel, you may need to update the migrations table to include the module name. You can do this by modifying the getConnection method in your module's service provider.