Compare commits

...

7 Commits
1.0.0 ... api

Author SHA1 Message Date
44f9593644 fixing sonarcube 2023-06-07 10:26:03 +07:00
d09915c09b Add API Usage Example 2023-05-29 04:21:02 +00:00
6c0d2bf4ce Update 'readme.md' 2023-05-28 02:26:08 +00:00
4935e04bf5 Update 'readme.md' 2023-05-27 16:26:30 +00:00
48de246084 Update 'readme.md' 2023-05-27 16:25:44 +00:00
bd50f18f77 Update 'readme.md' 2023-05-27 16:25:19 +00:00
2b9d78a7ee Add 'readme.md' 2023-05-27 16:12:09 +00:00
6 changed files with 103 additions and 41 deletions

View File

@ -1,26 +1,18 @@
<?php
namespace Modules\Auth\Database\Seeders;
namespace Modules\Auth\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class AuthDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run() : void
class AuthDatabaseSeeder extends Seeder
{
// \App\Models\User::factory(10)->create();
// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
// $this->call("OthersTableSeeder");
/**
* Run the database seeds.
*
* @return void
*/
public function run(): void
{
}
}
}

View File

@ -2,7 +2,6 @@
namespace Modules\Auth\Entities;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

View File

@ -16,8 +16,7 @@
*
* @return Renderable
*/
public function index()
: JsonResponse
public function index(): JsonResponse
{
$users = User::all();
return $this->sendResponse($users, 'Users retrieved successfully.');
@ -30,8 +29,7 @@
*
* @return Renderable
*/
public function store(Request $request)
: JsonResponse
public function store(Request $request): JsonResponse
{
$validator = Validator::make($request->all(), [
'name' => 'required',
@ -59,11 +57,11 @@
*
* @return Renderable
*/
public function show($id) : JsonResponse
public function show($id): JsonResponse
{
$user = User::find($id);
if (is_null($user)) {
return $this->sendError('User not found.',404);
return $this->sendError('User not found.', 404);
}
return $this->sendResponse($user, 'User retrieved successfully.');
@ -109,7 +107,7 @@
{
$user = User::find($id);
if (is_null($user)) {
return $this->sendError('User not found.',404);
return $this->sendError('User not found.', 404);
}
$user->delete();

View File

@ -51,7 +51,8 @@ class AuthServiceProvider extends ServiceProvider
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
], 'config');
$this->mergeConfigFrom(
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
module_path($this->moduleName, 'Config/config.php'),
$this->moduleNameLower
);
}

View File

@ -14,18 +14,6 @@ class RouteServiceProvider extends ServiceProvider
*/
protected $moduleNamespace = 'Modules\Auth\Http\Controllers';
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @return void
*/
public function boot()
{
parent::boot();
}
/**
* Define the routes for the application.
*

84
readme.md Normal file
View File

@ -0,0 +1,84 @@
# Install a module package (for private packages)
To install a module package open ***composer.json***
Add a repositories section :
```
"repositories": [
{
"name": "putrakuningan/auth-module",
"type": "vcs",
"url": "https://git.putrakuningan.com/putrakuningan/auth-module",
"branches-path": "api"
}
]
```
***branches-path according to what will be installed
And in the ***require*** section type:
```
"putrakuningan/auth-module": "^1.0"
```
Now you can run composer update to install the package.
Or you can install with :
```
composer require putrakuningan/auth-module:1.0.0
```
After add repositories
## Setup Module
To activate the module type:
```
php artisan module:enable Auth
```
Now the module is ready to be migrated and seeded:
```
php artisan module:migrate Auth
php artisan module:seed Auth
```
## Uninstall Packages
If you uninstall a package from composer.json the module WILL be removed from the modules directory.
# List & API Usage Example
Don't forget to add ``` Accept : application/json ``` on header every API Request
## Register
```
POST /api/register
```
```
{
"name" : "Demo",
"email" : "demo@demo.com",
"password" : "demo"
"passowrd_confirmation" : "demo"
}
```
## Login
```
POST /api/login
```
```
{
"email" : "demo@demo.com",
"password" : "demo"
}
```