diff --git a/app/Http/Controllers/PlayerController.php b/app/Http/Controllers/PlayerController.php index 8ada88e..13bbd83 100644 --- a/app/Http/Controllers/PlayerController.php +++ b/app/Http/Controllers/PlayerController.php @@ -137,7 +137,7 @@ class PlayerController extends Controller if ($certificate->count() == 0) { $certificate_data['user_id'] = auth()->user()->id; $certificate_data['course_id'] = $request->course_id; - $certificate_data['identifier'] = random(12); + $certificate_data['identifier'] = $this->generateIdentifier(12); $certificate_data['created_at'] = date('Y-m-d H:i:s'); Certificate::insert($certificate_data); } @@ -146,6 +146,22 @@ class PlayerController extends Controller return redirect()->back(); } + private function generateIdentifier($length = 12) + { + $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + + return $randomString; + } + + + + public function prepend_watermark() { return view('course_player.watermark'); diff --git a/app/Http/Controllers/frontend/HomeController.php b/app/Http/Controllers/frontend/HomeController.php index 85cb4ac..7addf79 100644 --- a/app/Http/Controllers/frontend/HomeController.php +++ b/app/Http/Controllers/frontend/HomeController.php @@ -60,6 +60,8 @@ class HomeController extends Controller $page_data['certificate'] = $certificate->first(); $page_data['qrcode'] = $qrcode; + + // dd($qr_code_content_value); return view('curriculum.certificate.download', $page_data); } else { return redirect(route('home'))->with('error', get_phrase('Certificate not found at this url')); diff --git a/app/Http/Controllers/student/QuizController.php b/app/Http/Controllers/student/QuizController.php index b78949f..5b04961 100644 --- a/app/Http/Controllers/student/QuizController.php +++ b/app/Http/Controllers/student/QuizController.php @@ -208,7 +208,7 @@ class QuizController extends Controller Certificate::create([ 'user_id' => $student_id, 'course_id' => $course_id, - 'identifier' => substr(md5(uniqid(mt_rand(), true)), 0, 10), // Generate random ID + 'identifier' => $this->generateIdentifier(12), ]); } } @@ -216,6 +216,18 @@ class QuizController extends Controller return true; } + private function generateIdentifier($length = 12) + { + $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + + return $randomString; + } + public function load_result(Request $request) { $page_data['quiz'] = Lesson::where('id', $request->quiz_id)->first(); diff --git a/public/uploads/certificate-template/certificate-default.png b/public/uploads/certificate-template/certificate-default.png deleted file mode 100644 index 0fc72bb..0000000 Binary files a/public/uploads/certificate-template/certificate-default.png and /dev/null differ diff --git a/public/uploads/certificate-template/optimized/certificate-default.png b/public/uploads/certificate-template/optimized/certificate-default.png deleted file mode 100644 index f38307c..0000000 Binary files a/public/uploads/certificate-template/optimized/certificate-default.png and /dev/null differ diff --git a/resources/views/admin/certificate/builder.blade.php b/resources/views/admin/certificate/builder.blade.php index 65267ce..b628cc9 100644 --- a/resources/views/admin/certificate/builder.blade.php +++ b/resources/views/admin/certificate/builder.blade.php @@ -15,20 +15,31 @@ + {{-- Font Awesome untuk ikon tambahan --}} + + - - - - - - - +