This commit is contained in:
Azfar Arsyad
2022-01-16 17:05:43 +08:00
parent e2072ecd78
commit 679d756bf1
4 changed files with 46 additions and 64 deletions
@@ -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();
}
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class File extends Model
{
use HasFactory;
protected $table = 'file';
protected $fillable = [
'user_id',
'file_type',
'filename',
'deleted_at',
'deleted_by'
];
}
-2
View File
@@ -35,8 +35,6 @@ class User extends Authenticatable
't_daftar',
'online',
'register_agree',
'front_img_path',
'back_img_path',
'disahkan_pada',
'disahkan_oleh'
@@ -32,11 +32,6 @@ class CreateUsersTable extends Migration
$table->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