Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
44f9593644 | |||
d09915c09b | |||
6c0d2bf4ce | |||
4935e04bf5 | |||
48de246084 | |||
bd50f18f77 | |||
2b9d78a7ee |
@ -1,26 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Auth\Database\Seeders;
|
namespace Modules\Auth\Database\Seeders;
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class AuthDatabaseSeeder extends Seeder
|
class AuthDatabaseSeeder extends Seeder
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the database seeds.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function run() : void
|
|
||||||
{
|
{
|
||||||
// \App\Models\User::factory(10)->create();
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
// \App\Models\User::factory()->create([
|
*
|
||||||
// 'name' => 'Test User',
|
* @return void
|
||||||
// 'email' => 'test@example.com',
|
*/
|
||||||
// ]);
|
public function run(): void
|
||||||
|
{
|
||||||
// $this->call("OthersTableSeeder");
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Modules\Auth\Entities;
|
namespace Modules\Auth\Entities;
|
||||||
|
|
||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(): JsonResponse
|
||||||
: JsonResponse
|
|
||||||
{
|
{
|
||||||
$users = User::all();
|
$users = User::all();
|
||||||
return $this->sendResponse($users, 'Users retrieved successfully.');
|
return $this->sendResponse($users, 'Users retrieved successfully.');
|
||||||
@ -30,8 +29,7 @@
|
|||||||
*
|
*
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request): JsonResponse
|
||||||
: JsonResponse
|
|
||||||
{
|
{
|
||||||
$validator = Validator::make($request->all(), [
|
$validator = Validator::make($request->all(), [
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
@ -59,11 +57,11 @@
|
|||||||
*
|
*
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function show($id) : JsonResponse
|
public function show($id): JsonResponse
|
||||||
{
|
{
|
||||||
$user = User::find($id);
|
$user = User::find($id);
|
||||||
if (is_null($user)) {
|
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.');
|
return $this->sendResponse($user, 'User retrieved successfully.');
|
||||||
@ -109,7 +107,7 @@
|
|||||||
{
|
{
|
||||||
$user = User::find($id);
|
$user = User::find($id);
|
||||||
if (is_null($user)) {
|
if (is_null($user)) {
|
||||||
return $this->sendError('User not found.',404);
|
return $this->sendError('User not found.', 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->delete();
|
$user->delete();
|
||||||
|
@ -51,7 +51,8 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||||
], 'config');
|
], 'config');
|
||||||
$this->mergeConfigFrom(
|
$this->mergeConfigFrom(
|
||||||
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
module_path($this->moduleName, 'Config/config.php'),
|
||||||
|
$this->moduleNameLower
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,18 +14,6 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
protected $moduleNamespace = 'Modules\Auth\Http\Controllers';
|
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.
|
* Define the routes for the application.
|
||||||
*
|
*
|
||||||
|
84
readme.md
Normal file
84
readme.md
Normal 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"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue
Block a user