Skip to content

Commit

Permalink
Merge pull request #87 from andes2912/Bug-fix/add-customers
Browse files Browse the repository at this point in the history
Bug fix add customer
  • Loading branch information
andes2912 authored May 18, 2022
2 parents 09e5c07 + 5dfc0d9 commit ac5e780
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions app/Http/Controllers/Karyawan/CustomerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace App\Http\Controllers\Karyawan;

use App\Http\Controllers\Controller;
use Auth;
use Session;
use ErrorException;
use App\Models\User;
use Illuminate\Http\Request;
Expand All @@ -13,7 +11,10 @@
use Illuminate\Support\Facades\Hash;
use App\Jobs\RegisterCustomerJob;
use Mail;
use DB;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
class CustomerController extends Controller
{
// index
Expand Down Expand Up @@ -55,7 +56,7 @@ public function store(AddCustomerRequest $request)
$removeNol = $request->no_telp; // Balikan jika format sudah benar
}

$password =$this->acakpass(8);
$password = str::random(8);

$addCustomer = User::create([
'karyawan_id' => Auth::id(),
Expand Down Expand Up @@ -91,15 +92,4 @@ public function store(AddCustomerRequest $request)
throw new ErrorException($e->getMessage());
}
}

// Acak Password
private function acakpass($long){
$huruf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'; //buat karakter yang akan digunakan sebagai password
$st = '';
for($i=0; $i<$long; $i++){
$p = rand(0, strlen($huruf)-1);
$st .=$huruf{$p};
}
return $st;
}
}

0 comments on commit ac5e780

Please sign in to comment.