first
This commit is contained in:
40
app/Services/Admin/PusatQrCodeService.php
Normal file
40
app/Services/Admin/PusatQrCodeService.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user