From 679d756bf173487997c2aba98e150e89308f8dfa Mon Sep 17 00:00:00 2001 From: Azfar Arsyad <45238748+Arpax17@users.noreply.github.com> Date: Sun, 16 Jan 2022 17:05:43 +0800 Subject: [PATCH] register --- .../Controllers/AuthMobile/AuthController.php | 82 ++++++------------- app/Models/File.php | 21 +++++ app/Models/User.php | 2 - .../2014_10_12_000000_create_users_table.php | 5 -- 4 files changed, 46 insertions(+), 64 deletions(-) create mode 100644 app/Models/File.php diff --git a/app/Http/Controllers/AuthMobile/AuthController.php b/app/Http/Controllers/AuthMobile/AuthController.php index 61cd3f6a..cccc1271 100644 --- a/app/Http/Controllers/AuthMobile/AuthController.php +++ b/app/Http/Controllers/AuthMobile/AuthController.php @@ -21,7 +21,7 @@ class AuthController extends Controller 'password' => 'required|string|confirmed', 'notelbimbit' => 'required|string', 'register_agree' => 'required|integer', - 'email' => 'required|string|unique:users,email', + // 'email' => 'required|string|unique:users,email', // 'front_img' => 'required|mimes:jpg,png,jpeg|max:5048', // 'back_img' => 'required|mimes:jpg,png,jpeg|max:5048' @@ -34,69 +34,37 @@ class AuthController extends Controller $user->password = $request->input('password'); $user->notelbimbit = $request->input('notelbimbit'); $user->register_agree = $request->input('register_agree'); - $user->email = $request->input('email'); + // $user->email = $request->input('email'); if(isset($name) && isset($username) && isset($nokp) && isset($password) && isset($notelbimbit) && isset($register_agree) ){ - $images = new File(); - foreach($images as $image){ - - $image->front_img_filename = $request->input('front_img_filename'); - $image->back_img_filename = $request->input('back_img_filename'); - - // $image = base64_encode(file_get_contents($image)); - - // if(null !== ['front_img'] && null !== ['back_img']){ - - // // foreach() { - // $newFrontImageName = time().'.' . explode('/', explode(':', substr($request->front_img, 0, strpos($request->front_img, ';')))[1])[1]; - // $newBackImageName = time().'.' . explode('/', explode(':', substr($request->back_img, 0, strpos($request->back_img, ';')))[1])[1]; - - // \Image::make($request->front_img)->save(ppublic_path('ic/'.$folder_name).$newFrontImageName); - // \Image::make($request->back_img)->save(ppublic_path('ic/'.$folder_name).$newBackImageName); - - // $userPhoto = public_path('ic/'.$folder_name).$currentPhoto; - // // } - - // // //create a filename - // // $newFrontImageName = 'front-' . $request->nokp . '.' . $request->front_img->extension(); - - // // $newBackImageName = 'back-' . $request->nokp . '.' . $request->back_img->extension(); - - // // //save image in folder ic - // // $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'], - 'email' => $fields['email'], - 'nokp' => $fields['nokp'], - 'password' => bcrypt($fields['password']), - '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'], - - ]); + $user = new User; + $user->name = $fields['name']; + $user->username = $fields['username']; + $user->nokp = $fields['nokp']; + $user->password = bcrypt($fields['password']); + $user->notelbimbit = $fields['notelbimbit']; + $user->register_agree = $fields['register_agree']; + $user->t_daftar = $currentdate; + $user->type = 2; //type 2 = pembida + $images = $request->images; + + if($user->save()) + { + foreach($images as $img) + { + $file = new File; + $file->user_id = $user->id; + $file->file_type = $img->file_type; + $file->filename = $img->filename; + $file->save(); + } + } + } diff --git a/app/Models/File.php b/app/Models/File.php new file mode 100644 index 00000000..068f0c73 --- /dev/null +++ b/app/Models/File.php @@ -0,0 +1,21 @@ +string('email')->nullable(); $table->datetime('email_verified_at')->nullable(); $table->string('password'); - // $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