register
@@ -1,61 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers\AuthMobile;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class AuthController extends Controller
|
class AuthController extends Controller
|
||||||
{
|
{
|
||||||
public function register(Request $request) {
|
public function register(Request $request) {
|
||||||
|
|
||||||
$fields = $request->validate([
|
$fields = $request->validate([
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'username' => 'required|string|unique:users,username',
|
'username' => 'required|string|unique:users,username',
|
||||||
'kodcaw' => 'required|string',
|
|
||||||
'bank_acc_pembeli' => 'required|string',
|
|
||||||
'bank_acc_no_pembeli' => 'required|string',
|
|
||||||
'alamat_rumah' => 'required|string',
|
|
||||||
'notelpejabat' => 'required|string',
|
|
||||||
'notelbimbit' => 'required|string',
|
|
||||||
'note' => 'string',
|
|
||||||
'status' => 'required|string',
|
|
||||||
't_daftar' => 'required|date',
|
|
||||||
'online' => 'integer',
|
|
||||||
'register_agree' => 'required|integer',
|
|
||||||
'email' => 'required|string|unique:users,email',
|
'email' => 'required|string|unique:users,email',
|
||||||
|
'nokp' => 'required|string|unique:users,nokp',
|
||||||
'password' => 'required|string|confirmed',
|
'password' => 'required|string|confirmed',
|
||||||
'front_img_path' => 'required|mimes:jpg,png,jpeg|max:5048',
|
'notelbimbit' => 'required|string',
|
||||||
'back_img_path' => 'required|mimes:jpg,png,jpeg|max:5048'
|
'register_agree' => 'required|integer',
|
||||||
|
'front_img' => 'required|mimes:jpg,png,jpeg|max:5048',
|
||||||
|
'back_img' => 'required|mimes:jpg,png,jpeg|max:5048'
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$newFrontImageName = time() . '-' . $request->name . '.' . $request->front_img_path->extension();
|
$newFrontImageName = 'front-' . $request->nokp . '.' . $request->front_img->extension();
|
||||||
|
|
||||||
$newBackImageName = time() . '-' . $request->username . '.' . $request->back_img_path->extension();
|
$newBackImageName = 'back-' . $request->nokp . '.' . $request->back_img->extension();
|
||||||
|
|
||||||
$request->front_img_path->move(public_path('ic'), $newFrontImageName);
|
// $request->front_img->move(public_path() . '/ic/', $newFrontImageName);
|
||||||
|
// $request->back_img->move(public_path() . '/ic/', $newBackImageName);
|
||||||
|
|
||||||
$request->back_img_path->move(public_path('ic'), $newBackImageName);
|
// $request->ic_image_path->getRealPath()->store('front_img','back_img');
|
||||||
|
|
||||||
|
|
||||||
|
$folder_name = $request->nokp;
|
||||||
|
$request->front_img->move(public_path('/ic/'.$folder_name), $newFrontImageName);
|
||||||
|
$request->back_img->move(public_path('/ic/'.$folder_name), $newBackImageName);
|
||||||
|
|
||||||
|
$currentdate = Carbon::now();
|
||||||
|
$currentdate = $currentdate->toDateString();
|
||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'name' => $fields['name'],
|
'name' => $fields['name'],
|
||||||
'username' => $fields['username'],
|
'username' => $fields['username'],
|
||||||
'kodcaw' => $fields['kodcaw'],
|
|
||||||
'bank_acc_pembeli' => $fields['bank_acc_pembeli'],
|
|
||||||
'bank_acc_no_pembeli' => $fields['bank_acc_no_pembeli'],
|
|
||||||
'alamat_rumah' => $fields['alamat_rumah'],
|
|
||||||
'notelpejabat' => $fields['notelpejabat'],
|
|
||||||
'notelbimbit' => $fields['notelbimbit'],
|
|
||||||
'status' => $fields['status'],
|
|
||||||
't_daftar' => $fields['t_daftar'],
|
|
||||||
'online' => $fields['online'],
|
|
||||||
'register_agree' => $fields['register_agree'],
|
|
||||||
'email' => $fields['email'],
|
'email' => $fields['email'],
|
||||||
|
'nokp' => $fields['nokp'],
|
||||||
'password' => bcrypt($fields['password']),
|
'password' => bcrypt($fields['password']),
|
||||||
'front_img_path' => $newFrontImageName,
|
'notelbimbit' => $fields['notelbimbit'],
|
||||||
'back_img_path' => $newBackImageName
|
'register_agree' => $fields['register_agree'],
|
||||||
|
't_daftar' => $currentdate,
|
||||||
|
'ic_image_path' => 'ic'.$folder_name,
|
||||||
|
'front_img' => $newFrontImageName,
|
||||||
|
'back_img' => $newBackImageName
|
||||||
|
|
||||||
|
// 'notelpejabat' => $fields['notelpejabat'],
|
||||||
|
// 'status' => $fields['status'],
|
||||||
|
// 'online' => $fields['online'],
|
||||||
|
// 'kodcaw' => $fields['kodcaw'],
|
||||||
|
// 'bank_acc_pembeli' => $fields['bank_acc_pembeli'],
|
||||||
|
// 'bank_acc_no_pembeli' => $fields['bank_acc_no_pembeli'],
|
||||||
|
// 'alamat_rumah' => $fields['alamat_rumah'],
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -65,6 +72,11 @@ class AuthController extends Controller
|
|||||||
'token' => $token
|
'token' => $token
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// return back()
|
||||||
|
|
||||||
|
// ->with('success','You have successfully upload image.')
|
||||||
|
|
||||||
|
// ->with('image',$imageName);
|
||||||
return response($response, 201);
|
return response($response, 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Kernel extends HttpKernel
|
|||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
|
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||||
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||||
'throttle:api',
|
'throttle:api',
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
|||||||
@@ -16,26 +16,30 @@ class CreateUsersTable extends Migration
|
|||||||
Schema::create('users', function (Blueprint $table) {
|
Schema::create('users', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
|
$table->string('username')->unique();
|
||||||
$table->string('kodcaw')->nullable();
|
$table->string('kodcaw')->nullable();
|
||||||
$table->string('nokp')->nullable();
|
$table->string('nokp')->nullable();
|
||||||
$table->string('bank_acc_pembeli')->nullable();
|
$table->string('bank_acc_pembeli')->nullable();
|
||||||
$table->string('bank_acc_no_pembeli')->nullable();
|
$table->string('bank_acc_no_pembeli')->nullable();
|
||||||
$table->string('alamat_rumah')->nullable();
|
$table->string('alamat')->nullable();
|
||||||
$table->string('notelpejabat')->nullable();
|
$table->string('notelpejabat')->nullable();
|
||||||
$table->string('notelbimbit')->nullable();
|
$table->string('notelbimbit')->nullable();
|
||||||
$table->string('note')->nullable();
|
$table->string('note')->nullable(); //operasi
|
||||||
$table->string('status')->nullable();
|
$table->string('status')->nullable(); //set
|
||||||
$table->datetime('t_daftar')->nullable();
|
$table->datetime('t_daftar')->nullable();
|
||||||
$table->integer('online')->nullable();
|
$table->integer('online')->nullable(); //set
|
||||||
$table->integer('register_agree')->nullable();
|
$table->integer('register_agree')->nullable();
|
||||||
$table->string('username')->unique();
|
|
||||||
$table->string('email')->nullable();
|
$table->string('email')->nullable();
|
||||||
$table->datetime('email_verified_at')->nullable();
|
$table->datetime('email_verified_at')->nullable();
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->string('front_img_path');
|
// $table->string('front_img_path');
|
||||||
$table->string('back_img_path');
|
// $table->string('back_img_path');
|
||||||
$table->datetime('disahkan_pada');
|
$table->string('ic_image_path')->nullable();
|
||||||
$table->datetime('disahkan_oleh');
|
$table->string('front_img_filename')->nullable();
|
||||||
|
$table->string('back_img_filename')->nullable();
|
||||||
|
$table->datetime('disahkan_pada')->nullable();
|
||||||
|
$table->datetime('disahkan_oleh')->nullable();
|
||||||
|
$table->string('user_type')->nullable(); //set 1,2
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|||||||
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 10 KiB |
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use App\Http\Controllers\AuthController;
|
use App\Http\Controllers\AuthMobile\AuthController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||