- Mail campaign: mẫu nhắc gia hạn thanh toán QR, chọn dịch vụ + chu kỳ từng dòng (renewal_services) - Hosting: nhiều server Plesk cho một gói (service_plan_servers), chuyển server khi server chết - Admin xem/sửa giấy tờ định danh khách, tuỳ chọn gia hạn cho khách, nhật ký cấp phát dịch vụ - Đánh dấu mẫu email dịch vụ là non-marketing Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Models\Customer;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Facades\URL;
|
|
|
|
class CustomerIdentity
|
|
{
|
|
public const SIDES = ['front' => 'front_identity_number', 'back' => 'back_identity_number'];
|
|
|
|
public static function payload(Customer $customer): array
|
|
{
|
|
return [
|
|
'identity_number' => $customer->identity_number,
|
|
'front_url' => self::signedUrl($customer, 'front'),
|
|
'back_url' => self::signedUrl($customer, 'back'),
|
|
];
|
|
}
|
|
|
|
public static function response(Customer $customer, string $side)
|
|
{
|
|
$disk = self::diskFor($customer->{self::SIDES[$side]});
|
|
abort_unless($disk, 404);
|
|
|
|
return Storage::disk($disk)->response($customer->{self::SIDES[$side]}, null, ['Cache-Control' => 'private, no-store']);
|
|
}
|
|
|
|
private static function signedUrl(Customer $customer, string $side): ?string
|
|
{
|
|
if (! self::diskFor($customer->{self::SIDES[$side]})) {
|
|
return null;
|
|
}
|
|
|
|
return URL::temporarySignedRoute(
|
|
'admin.customers.identity-image',
|
|
now()->addHour(),
|
|
['customer' => $customer->uuid, 'side' => $side],
|
|
);
|
|
}
|
|
|
|
private static function diskFor(?string $path): ?string
|
|
{
|
|
if (! is_string($path) || $path === '' || str_contains($path, '..')) {
|
|
return null;
|
|
}
|
|
|
|
foreach (['local', 'public'] as $disk) {
|
|
if (Storage::disk($disk)->exists($path)) {
|
|
return $disk;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|