Add Login & Register
This commit is contained in:
0
Modules/Linksehat/Config/.gitkeep
Normal file
0
Modules/Linksehat/Config/.gitkeep
Normal file
6
Modules/Linksehat/Config/config.php
Normal file
6
Modules/Linksehat/Config/config.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Linksehat',
|
||||
'otp_valid_minutes' => 10
|
||||
];
|
||||
0
Modules/Linksehat/Console/.gitkeep
Normal file
0
Modules/Linksehat/Console/.gitkeep
Normal file
0
Modules/Linksehat/Database/Migrations/.gitkeep
Normal file
0
Modules/Linksehat/Database/Migrations/.gitkeep
Normal file
0
Modules/Linksehat/Database/Seeders/.gitkeep
Normal file
0
Modules/Linksehat/Database/Seeders/.gitkeep
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LinksehatDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// $this->call("OthersTableSeeder");
|
||||
}
|
||||
}
|
||||
0
Modules/Linksehat/Database/factories/.gitkeep
Normal file
0
Modules/Linksehat/Database/factories/.gitkeep
Normal file
0
Modules/Linksehat/Entities/.gitkeep
Normal file
0
Modules/Linksehat/Entities/.gitkeep
Normal file
0
Modules/Linksehat/Http/Controllers/.gitkeep
Normal file
0
Modules/Linksehat/Http/Controllers/.gitkeep
Normal file
131
Modules/Linksehat/Http/Controllers/Api/AuthController.php
Normal file
131
Modules/Linksehat/Http/Controllers/Api/AuthController.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Validator;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function otpRequest(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'phone' => 'required'
|
||||
]);
|
||||
|
||||
$user = User::updateOrCreate([
|
||||
'phone' => $request->phone
|
||||
], [
|
||||
'phone' => $request->phone,
|
||||
'otp' => rand(1000, 9999),
|
||||
'otp_created_at' => now()
|
||||
]);
|
||||
if (!$user) {
|
||||
return response()->json([
|
||||
'message' => "User dengan nomor telepon ".$request->phone." tidak ditemukan"
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'OTP Terkirim',
|
||||
'data' => [
|
||||
'otp_valid_until' => $user->otp_created_at->addMinutes(config('linksehat.otp_valid_minutes'))
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'email',
|
||||
'password' => 'required_with:email',
|
||||
'phone' => '',
|
||||
'otp' => 'required_with:phone',
|
||||
]);
|
||||
|
||||
$loginType = null;
|
||||
|
||||
if ($request->has('password') && !empty($request->password)) {
|
||||
$user = User::query()
|
||||
->where('email', $request->email)
|
||||
->first();
|
||||
|
||||
$loginType = 'email';
|
||||
}
|
||||
|
||||
if ($request->has('otp') && !empty($request->otp)) {
|
||||
$user = User::query()
|
||||
->where('phone', $request->phone)
|
||||
->first();
|
||||
|
||||
$loginType = 'phone';
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
return response(['message' => 'User Tidak Ditemukan'], 404);
|
||||
}
|
||||
|
||||
if ($loginType == 'email') {
|
||||
if (!Hash::check($request->password, $user->password)) {
|
||||
return response(['message' => 'Password Salah'], 403);
|
||||
}
|
||||
} else if ($loginType == 'phone') {
|
||||
if ($request->otp != $user->otp) {
|
||||
return response(['message' => 'OTP Salah'], 403);
|
||||
}
|
||||
} else {
|
||||
return response(['message' => 'Mode Login Tidak Dikenal'], 403);
|
||||
}
|
||||
|
||||
return response([
|
||||
'message' => 'Selamat Datang',
|
||||
'user' => $user,
|
||||
'token' => $user->createToken('app')->plainTextToken
|
||||
]);
|
||||
}
|
||||
|
||||
public function register(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'password' => [
|
||||
'required',
|
||||
'confirmed',
|
||||
'min:8',
|
||||
'regex:/.*[0-9].*/',
|
||||
'regex:/.*[a-z].*/',
|
||||
'regex:/.*[A-Z].*/',
|
||||
]
|
||||
], [
|
||||
'password.regex' => "Password harus minimal 8 karakter, kombinasi huruf besar kecil dan angka"
|
||||
])->validate();
|
||||
|
||||
try {
|
||||
$user = User::create([
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Akun berhasil dibuat, silahkan cek E-mail untuk konfirmasi'
|
||||
], 201);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'message' => 'Terjadi masalah ketika mendaftar',
|
||||
'error_message' => $e->getMessage()
|
||||
], 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$token = $request->bearerToken();
|
||||
Auth::user()->tokens()->where('id', $token)->delete();
|
||||
|
||||
return response(['message' => 'Berhasil Logout.']);
|
||||
}
|
||||
}
|
||||
79
Modules/Linksehat/Http/Controllers/LinksehatController.php
Normal file
79
Modules/Linksehat/Http/Controllers/LinksehatController.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class LinksehatController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('linksehat::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('linksehat::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('linksehat::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('linksehat::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
0
Modules/Linksehat/Http/Middleware/.gitkeep
Normal file
0
Modules/Linksehat/Http/Middleware/.gitkeep
Normal file
0
Modules/Linksehat/Http/Requests/.gitkeep
Normal file
0
Modules/Linksehat/Http/Requests/.gitkeep
Normal file
0
Modules/Linksehat/Providers/.gitkeep
Normal file
0
Modules/Linksehat/Providers/.gitkeep
Normal file
112
Modules/Linksehat/Providers/LinksehatServiceProvider.php
Normal file
112
Modules/Linksehat/Providers/LinksehatServiceProvider.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
class LinksehatServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @var string $moduleName
|
||||
*/
|
||||
protected $moduleName = 'Linksehat';
|
||||
|
||||
/**
|
||||
* @var string $moduleNameLower
|
||||
*/
|
||||
protected $moduleNameLower = 'linksehat';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
|
||||
$sourcePath = module_path($this->moduleName, 'Resources/views');
|
||||
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath
|
||||
], ['views', $this->moduleNameLower . '-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerTranslations()
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (\Config::get('view.paths') as $path) {
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
69
Modules/Linksehat/Providers/RouteServiceProvider.php
Normal file
69
Modules/Linksehat/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $moduleNamespace = 'Modules\Linksehat\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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('Linksehat', '/Routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('Linksehat', '/Routes/api.php'));
|
||||
}
|
||||
}
|
||||
0
Modules/Linksehat/Resources/assets/.gitkeep
Normal file
0
Modules/Linksehat/Resources/assets/.gitkeep
Normal file
0
Modules/Linksehat/Resources/assets/js/app.js
Normal file
0
Modules/Linksehat/Resources/assets/js/app.js
Normal file
0
Modules/Linksehat/Resources/assets/sass/app.scss
Normal file
0
Modules/Linksehat/Resources/assets/sass/app.scss
Normal file
0
Modules/Linksehat/Resources/lang/.gitkeep
Normal file
0
Modules/Linksehat/Resources/lang/.gitkeep
Normal file
0
Modules/Linksehat/Resources/views/.gitkeep
Normal file
0
Modules/Linksehat/Resources/views/.gitkeep
Normal file
9
Modules/Linksehat/Resources/views/index.blade.php
Normal file
9
Modules/Linksehat/Resources/views/index.blade.php
Normal file
@@ -0,0 +1,9 @@
|
||||
@extends('linksehat::layouts.master')
|
||||
|
||||
@section('content')
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>
|
||||
This view is loaded from module: {!! config('linksehat.name') !!}
|
||||
</p>
|
||||
@endsection
|
||||
19
Modules/Linksehat/Resources/views/layouts/master.blade.php
Normal file
19
Modules/Linksehat/Resources/views/layouts/master.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Module Linksehat</title>
|
||||
|
||||
{{-- Laravel Mix - CSS File --}}
|
||||
{{-- <link rel="stylesheet" href="{{ mix('css/linksehat.css') }}"> --}}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Laravel Mix - JS File --}}
|
||||
{{-- <script src="{{ mix('js/linksehat.js') }}"></script> --}}
|
||||
</body>
|
||||
</html>
|
||||
0
Modules/Linksehat/Routes/.gitkeep
Normal file
0
Modules/Linksehat/Routes/.gitkeep
Normal file
23
Modules/Linksehat/Routes/api.php
Normal file
23
Modules/Linksehat/Routes/api.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Linksehat\Http\Controllers\Api\AuthController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::post('otp-request', [AuthController::class, 'otpRequest']);
|
||||
Route::post('login', [AuthController::class, 'login']);
|
||||
Route::post('register', [AuthController::class, 'register']);
|
||||
|
||||
Route::middleware('auth:api')->get('/linksehat', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
16
Modules/Linksehat/Routes/web.php
Normal file
16
Modules/Linksehat/Routes/web.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::prefix('linksehat')->group(function() {
|
||||
Route::get('/', 'LinksehatController@index');
|
||||
});
|
||||
0
Modules/Linksehat/Tests/Feature/.gitkeep
Normal file
0
Modules/Linksehat/Tests/Feature/.gitkeep
Normal file
0
Modules/Linksehat/Tests/Unit/.gitkeep
Normal file
0
Modules/Linksehat/Tests/Unit/.gitkeep
Normal file
23
Modules/Linksehat/composer.json
Normal file
23
Modules/Linksehat/composer.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "nwidart/linksehat",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Linksehat\\": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Modules/Linksehat/module.json
Normal file
13
Modules/Linksehat/module.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "Linksehat",
|
||||
"alias": "linksehat",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Linksehat\\Providers\\LinksehatServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": []
|
||||
}
|
||||
21
Modules/Linksehat/package.json
Normal file
21
Modules/Linksehat/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "mix",
|
||||
"watch": "mix watch",
|
||||
"watch-poll": "mix watch -- --watch-options-poll=1000",
|
||||
"hot": "mix watch --hot",
|
||||
"prod": "npm run production",
|
||||
"production": "mix --production"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^0.21.4",
|
||||
"dotenv": "^10.0.0",
|
||||
"dotenv-expand": "^5.1.0",
|
||||
"laravel-mix": "^6.0.31",
|
||||
"laravel-mix-merge-manifest": "^2.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"postcss": "^8.3.7"
|
||||
}
|
||||
}
|
||||
14
Modules/Linksehat/webpack.mix.js
Normal file
14
Modules/Linksehat/webpack.mix.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const dotenvExpand = require('dotenv-expand');
|
||||
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));
|
||||
|
||||
const mix = require('laravel-mix');
|
||||
require('laravel-mix-merge-manifest');
|
||||
|
||||
mix.setPublicPath('../../public').mergeManifest();
|
||||
|
||||
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/linksehat.js')
|
||||
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/linksehat.css');
|
||||
|
||||
if (mix.inProduction()) {
|
||||
mix.version();
|
||||
}
|
||||
11
app/Models/Address.php
Normal file
11
app/Models/Address.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Address extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -11,5 +11,14 @@ class Organization extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'type',
|
||||
'status',
|
||||
'description',
|
||||
'part_of',
|
||||
];
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'part_of', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ class User extends Authenticatable
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'phone',
|
||||
'otp',
|
||||
'otp_created_at'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,9 +16,13 @@ return new class extends Migration
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
// $table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('email')->unique()->nullable();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('password')->nullable();
|
||||
$table->string('phone')->unique()->nullable();
|
||||
$table->timestamp('phone_verified_at')->nullable();
|
||||
$table->string('otp', 10)->nullable();
|
||||
$table->timestamp('otp_created_at')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('addresses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('addressable');
|
||||
$table->string('use')->nullable();
|
||||
$table->string('type')->nullable();
|
||||
$table->text('text')->nullable();
|
||||
$table->text('line')->nullable();
|
||||
$table->foreignId('province_id')->nullable();
|
||||
$table->foreignId('city_id')->nullable();
|
||||
$table->foreignId('district_id')->nullable();
|
||||
$table->foreignId('village_id')->nullable();
|
||||
$table->string('postal_code')->nullable();
|
||||
$table->string('rt')->nullable();
|
||||
$table->string('rw')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('addresses');
|
||||
}
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
import { useFormContext, Controller } from 'react-hook-form';
|
||||
// @mui
|
||||
import { Switch, FormControlLabel, FormControlLabelProps } from '@mui/material';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -27,3 +28,29 @@ export default function RHFSwitch({ name, ...other }: Props) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// interface Props extends IProps {
|
||||
// valueTrue: any,
|
||||
// valueFalse: any,
|
||||
// }
|
||||
|
||||
// export function RHFSwitchEnum({ name, valueTrue, valueFalse, ...other}: Props) {
|
||||
// const { control } = useFormContext();
|
||||
// const [isChecked, setIsChecked] = useState(valueTrue === field.value);
|
||||
// useEffect(() => {
|
||||
// // setIsChecked()
|
||||
// }, [])
|
||||
|
||||
// return (
|
||||
// <FormControlLabel
|
||||
// control={
|
||||
// <Controller
|
||||
// name={name}
|
||||
// control={control}
|
||||
// render={({ field }) => <Switch {...field} checked={field.value} />}
|
||||
// />
|
||||
// }
|
||||
// {...other}
|
||||
// />
|
||||
// );
|
||||
// }
|
||||
@@ -325,6 +325,7 @@ export default function CorporateForm({ isEdit, currentCorporate }: Props) {
|
||||
<Grid item xs={12} md={4}>
|
||||
<Stack spacing={3}>
|
||||
<Card sx={{ p: 3 }}>
|
||||
{ JSON.stringify(values.active) }
|
||||
<RHFSwitch name="active" label="Is Company Active" />
|
||||
<Stack spacing={3} mt={2}>
|
||||
<Typography align="center">Company Logo</Typography>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"Internal": true,
|
||||
"Client": true
|
||||
"Client": true,
|
||||
"Linksehat": true
|
||||
}
|
||||
Reference in New Issue
Block a user