This commit is contained in:
faiqahzaman
2022-01-12 17:05:01 +08:00
parent 1b310fb068
commit 2e2ea60f40
14 changed files with 57 additions and 40 deletions
@@ -1,61 +1,68 @@
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers\AuthMobile;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Hash;
use Carbon\Carbon;
class AuthController extends Controller
{
public function register(Request $request) {
$fields = $request->validate([
'name' => 'required|string',
'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',
'nokp' => 'required|string|unique:users,nokp',
'password' => 'required|string|confirmed',
'front_img_path' => 'required|mimes:jpg,png,jpeg|max:5048',
'back_img_path' => 'required|mimes:jpg,png,jpeg|max:5048'
'notelbimbit' => 'required|string',
'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->move(public_path() . '/ic/', $newFrontImageName);
// $request->back_img->move(public_path() . '/ic/', $newBackImageName);
$request->front_img_path->move(public_path('ic'), $newFrontImageName);
// $request->ic_image_path->getRealPath()->store('front_img','back_img');
$request->back_img_path->move(public_path('ic'), $newBackImageName);
$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([
'name' => $fields['name'],
'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'],
'nokp' => $fields['nokp'],
'password' => bcrypt($fields['password']),
'front_img_path' => $newFrontImageName,
'back_img_path' => $newBackImageName
'notelbimbit' => $fields['notelbimbit'],
'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
];
// return back()
// ->with('success','You have successfully upload image.')
// ->with('image',$imageName);
return response($response, 201);
}