41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Admin;
|
|
|
|
use App\Models\PusatMengundi;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
|
|
|
class PusatQrCodeService
|
|
{
|
|
public function generate(PusatMengundi $pusatMengundi): PusatMengundi
|
|
{
|
|
$url = route('public.applications.create', [
|
|
'pusatMengundi' => $pusatMengundi->public_uuid,
|
|
]);
|
|
|
|
$path = 'qrcodes/pusat-mengundi/'.$pusatMengundi->public_uuid.'.svg';
|
|
|
|
Storage::disk('local')->put($path, QrCode::format('svg')
|
|
->size(320)
|
|
->margin(2)
|
|
->generate($url));
|
|
|
|
$pusatMengundi->forceFill([
|
|
'registration_url' => $url,
|
|
'qr_code_path' => $path,
|
|
])->save();
|
|
|
|
activity('admin_setup')
|
|
->performedOn($pusatMengundi)
|
|
->causedBy(auth()->user())
|
|
->withProperties([
|
|
'registration_url' => $url,
|
|
'qr_code_path' => $path,
|
|
])
|
|
->log('pusat_qr_generated');
|
|
|
|
return $pusatMengundi;
|
|
}
|
|
}
|