'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; } }