fix: QR code guna Storage::disk('public') — imej tidak papar di admin panel
Storage::put() guna default disk (local/private) menyebabkan fail disimpan
di storage/app/private/public/qrcodes/ tapi URL /storage/qrcodes/... cari
fail di storage/app/public/qrcodes/ melalui symlink — lokasi berbeza.
- QrCodeService: guna disk('public'), path ringkas 'qrcodes/{token}.png'
- View: Storage::disk('public')->url() untuk URL yang betul
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,25 +12,21 @@ class QrCodeService
|
|||||||
{
|
{
|
||||||
public function generateForProgram(Program $program): ProgramQrCode
|
public function generateForProgram(Program $program): ProgramQrCode
|
||||||
{
|
{
|
||||||
// Deactivate existing active QR codes
|
|
||||||
$program->qrCodes()->where('is_active', true)->update(['is_active' => false]);
|
$program->qrCodes()->where('is_active', true)->update(['is_active' => false]);
|
||||||
|
|
||||||
$token = Str::random(48);
|
$token = Str::random(48);
|
||||||
$url = route('public.checkin.show', $token);
|
$url = route('public.checkin.show', $token);
|
||||||
$path = 'public/qrcodes/' . $token . '.png';
|
$path = 'qrcodes/' . $token . '.png';
|
||||||
$absPath = Storage::path($path);
|
|
||||||
|
|
||||||
// Ensure directory exists
|
Storage::disk('public')->makeDirectory('qrcodes');
|
||||||
Storage::makeDirectory('public/qrcodes');
|
|
||||||
|
|
||||||
// Generate QR code PNG (400×400, with quiet zone)
|
|
||||||
$png = QrCode::format('png')
|
$png = QrCode::format('png')
|
||||||
->size(400)
|
->size(400)
|
||||||
->margin(2)
|
->margin(2)
|
||||||
->errorCorrection('H')
|
->errorCorrection('H')
|
||||||
->generate($url);
|
->generate($url);
|
||||||
|
|
||||||
Storage::put($path, $png);
|
Storage::disk('public')->put($path, $png);
|
||||||
|
|
||||||
return $program->qrCodes()->create([
|
return $program->qrCodes()->create([
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
@@ -41,11 +37,11 @@ class QrCodeService
|
|||||||
|
|
||||||
public function getPublicUrl(ProgramQrCode $qrCode): string
|
public function getPublicUrl(ProgramQrCode $qrCode): string
|
||||||
{
|
{
|
||||||
return Storage::url($qrCode->qr_image_path);
|
return Storage::disk('public')->url($qrCode->qr_image_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRawPng(ProgramQrCode $qrCode): string
|
public function getRawPng(ProgramQrCode $qrCode): string
|
||||||
{
|
{
|
||||||
return Storage::get($qrCode->qr_image_path);
|
return Storage::disk('public')->get($qrCode->qr_image_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
@if($qrCode)
|
@if($qrCode)
|
||||||
{{-- QR Code Image --}}
|
{{-- QR Code Image --}}
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<img src="{{ Storage::url($qrCode->qr_image_path) }}"
|
<img src="{{ Storage::disk('public')->url($qrCode->qr_image_path) }}"
|
||||||
alt="QR Code {{ $program->title }}"
|
alt="QR Code {{ $program->title }}"
|
||||||
class="img-fluid border rounded p-2"
|
class="img-fluid border rounded p-2"
|
||||||
style="max-width: 280px;">
|
style="max-width: 280px;">
|
||||||
|
|||||||
Reference in New Issue
Block a user