The User Management module is a pre-built and maintained module that provides all the necessary functionality for user manangement in a Laravel project. The module includes features such as user create, users list, fetch user by id, udpate user information, delete user, fetch roles assigned to user, assign roles to user and remove role assign to user. By using this module, developers can save time and effort in implementing these common user management features in their projects, while promoting consistency and standardization in module design and implementation.for this module we are using the JWT Authentication
composer require nwidart/laravel-modules
Step 1.1: Create Modules folder on root laravel project also register in composer.json
{
"autoload": {
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/"
}
}
}
Tip: don't forget to run composer dump-autoload afterwards
if don't have Modules folder on laravel root then create manually.
git clone https://github.com/Hestabit/UserManagement
Tip: don't forget to run php artisan module:enable UserManagement afterwards
Step 2:- Run php artisan migrate
- User List
- Create User
- Fecth User Details By Id
- Update User
- Delete User
- Fetch The Roles Assign To User
- Assign Role To User
- Audit Logs
URL:- /api/users
Method:- GET
Request Body:-
Parameter | Type | Required | Description |
---|---|---|---|
token | string | Yes | JWT Token |
URL:- /api/users/store
Method:- POST
Request Body:-
Parameter | Type | Required | Description |
---|---|---|---|
name | string | Yes | Name of the user |
Yes | Email of the user | ||
password | string | Yes | Password of the user |
password_confirmation | string | Yes | Confirm Pasword |
token | string | Yes | JWT Token |
URL:- /api/users/{id}
Method:- GET
Request Body:-
Parameter | Type | Required | Description |
---|---|---|---|
token | string | Yes | JWT Token |
URL:- /api/users/update
Method:- PUT
Request Body:-
Parameter | Type | Required | Description |
---|---|---|---|
token | string | Yes | JWT Token |
name | string | Yes | Name of the user |
Yes | Email of the user |
URL:- /api/users/{id}
Method:- DELETE
Request Body:-
Parameter | Type | Required | Description |
---|---|---|---|
token | string | Yes | JWT Token |
URL:- /api/user/{id}/roles
Method:- GET
Request Body:-
Parameter | Type | Required | Description |
---|---|---|---|
token | string | Yes | JWT Token |
URL:- /api/user/{id}/role
Method:- POST
Request Body:-
Parameter | Type | Required | Description |
---|---|---|---|
token | string | Yes | JWT Token |
role_id | integer | Yes | Role Id |
URL:- /api/user/{id}/role/{role_id}
Method:- DELETE
Parameter | Type | Required | Description |
---|---|---|---|
token | string | Yes | JWT Token |
php artisan test Modules/UserManagement/Tests/Unit/UsersControllerTest.php