diff --git a/app/Http/Controllers/AuthMobile/AuthController.php b/app/Http/Controllers/AuthMobile/AuthController.php index 988b47a7..d997b71b 100644 --- a/app/Http/Controllers/AuthMobile/AuthController.php +++ b/app/Http/Controllers/AuthMobile/AuthController.php @@ -1,61 +1,68 @@ 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); } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 15eba476..7eb4d24d 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -40,6 +40,7 @@ class Kernel extends HttpKernel ], 'api' => [ + // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 'throttle:api', \Illuminate\Routing\Middleware\SubstituteBindings::class, diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index f2ba0356..32eb9522 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -16,26 +16,30 @@ class CreateUsersTable extends Migration Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); + $table->string('username')->unique(); $table->string('kodcaw')->nullable(); $table->string('nokp')->nullable(); $table->string('bank_acc_pembeli')->nullable(); $table->string('bank_acc_no_pembeli')->nullable(); - $table->string('alamat_rumah')->nullable(); + $table->string('alamat')->nullable(); $table->string('notelpejabat')->nullable(); $table->string('notelbimbit')->nullable(); - $table->string('note')->nullable(); - $table->string('status')->nullable(); + $table->string('note')->nullable(); //operasi + $table->string('status')->nullable(); //set $table->datetime('t_daftar')->nullable(); - $table->integer('online')->nullable(); + $table->integer('online')->nullable(); //set $table->integer('register_agree')->nullable(); - $table->string('username')->unique(); $table->string('email')->nullable(); $table->datetime('email_verified_at')->nullable(); $table->string('password'); - $table->string('front_img_path'); - $table->string('back_img_path'); - $table->datetime('disahkan_pada'); - $table->datetime('disahkan_oleh'); + // $table->string('front_img_path'); + // $table->string('back_img_path'); + $table->string('ic_image_path')->nullable(); + $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->timestamps(); }); diff --git a/public/ic/12345603234/back-12345603234.jpg b/public/ic/12345603234/back-12345603234.jpg new file mode 100644 index 00000000..70ceed66 Binary files /dev/null and b/public/ic/12345603234/back-12345603234.jpg differ diff --git a/public/ic/12345603234/front-12345603234.jpg b/public/ic/12345603234/front-12345603234.jpg new file mode 100644 index 00000000..c1b4c3c3 Binary files /dev/null and b/public/ic/12345603234/front-12345603234.jpg differ diff --git a/public/ic/1234560323434/back-1234560323434.jpg b/public/ic/1234560323434/back-1234560323434.jpg new file mode 100644 index 00000000..70ceed66 Binary files /dev/null and b/public/ic/1234560323434/back-1234560323434.jpg differ diff --git a/public/ic/1234560323434/front-1234560323434.jpg b/public/ic/1234560323434/front-1234560323434.jpg new file mode 100644 index 00000000..c1b4c3c3 Binary files /dev/null and b/public/ic/1234560323434/front-1234560323434.jpg differ diff --git a/public/ic/back-1234560323434.jpg b/public/ic/back-1234560323434.jpg new file mode 100644 index 00000000..70ceed66 Binary files /dev/null and b/public/ic/back-1234560323434.jpg differ diff --git a/public/ic/front-1234560323434.jpg b/public/ic/front-1234560323434.jpg new file mode 100644 index 00000000..c1b4c3c3 Binary files /dev/null and b/public/ic/front-1234560323434.jpg differ diff --git a/public/ic/u74324323243/back-u74324323243.jpg b/public/ic/u74324323243/back-u74324323243.jpg new file mode 100644 index 00000000..70ceed66 Binary files /dev/null and b/public/ic/u74324323243/back-u74324323243.jpg differ diff --git a/public/ic/u74324323243/front-u74324323243.jpg b/public/ic/u74324323243/front-u74324323243.jpg new file mode 100644 index 00000000..c1b4c3c3 Binary files /dev/null and b/public/ic/u74324323243/front-u74324323243.jpg differ diff --git a/public/ic_image_path/back-123456032345.jpg b/public/ic_image_path/back-123456032345.jpg new file mode 100644 index 00000000..70ceed66 Binary files /dev/null and b/public/ic_image_path/back-123456032345.jpg differ diff --git a/public/ic_image_path/front-123456032345.jpg b/public/ic_image_path/front-123456032345.jpg new file mode 100644 index 00000000..c1b4c3c3 Binary files /dev/null and b/public/ic_image_path/front-123456032345.jpg differ diff --git a/routes/api.php b/routes/api.php index 9345aa0a..7c53bd5a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -2,7 +2,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; -use App\Http\Controllers\AuthController; +use App\Http\Controllers\AuthMobile\AuthController; /* |--------------------------------------------------------------------------