Level 11
Also i am running it locally using Herd and Ngrok
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I tried uploading a pdf and i keep getting the errro only for pdf upload.
<?php
namespace App\Livewire\Dashboard\UserDashboard\Verification\Country\Nigeria\Components;
use Livewire\Component;
use Livewire\WithFileUploads;
class AddressVerification extends Component
{
use WithFileUploads;
public $pdf;
public $address;
public $custom_google_address;
public $message;
public $matched_address;
protected $rules = [
'pdf' => 'required|file|mimes:pdf',
'address' => 'required|string',
'custom_google_address' => 'nullable|string',
];
public function verifyAddress()
{
$this->validate();
$pdfFile = $this->pdf;
$address = strtolower(trim($this->address));
$customAddress = $this->custom_google_address;
// Parse PDF
try {
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($pdfFile->getRealPath());
$rawText = $pdf->getText();
$normalizedText = preg_replace('/\s+/', ' ', strtolower($rawText));
$matchFound = str_contains($normalizedText, $address);
$matchedLine = null;
if ($matchFound) {
preg_match_all('/\d{1,5}[^.,\n]*' . preg_quote($address, '/') . '[^.,\n]*/i', $rawText, $matches);
$matchedLine = $matches[0][0] ?? $address;
}
$this->message = $matchFound
? '✅ Address found in the PDF'
: '❌ Address not found in the PDF';
$this->matched_address = $matchedLine;
$this->custom_google_address = $customAddress;
} catch (\Exception $e) {
$this->message = 'Error parsing PDF: ' . $e->getMessage();
$this->matched_address = null;
}
}
public function render()
{
return view('livewire.dashboard');
}
}
Please or to participate in this conversation.