Livewire not finding component?

I've created a resource with a view page. When I visit the page I get an error saying Undefined variable $jobStatus. The error is generated from the blade view. I've gone over the code and can't see the error. It's probably something simple but I'm missing it. Any help is appreciated. On the view page I'm calling a livewire component like this:
class ViewPanImport extends ViewRecord
{
protected static string $resource = PanImportResource::class;

protected static string $view = 'livewire.pan-import-progress';

}
class ViewPanImport extends ViewRecord
{
protected static string $resource = PanImportResource::class;

protected static string $view = 'livewire.pan-import-progress';

}
This is the view at the path resources/views/livewire/pan-import-progress.blade.php
<div wire:poll.5s="checkJobStatus">
@if ($jobStatus === 0)
<p>The import is in progress.</p>
<x-filament::loading-indicator class="h-10 w-10 text-primary-500" />
@elseif ($jobStatus === 1)
<p>The import is finished.</p>
@endif
</div>
<div wire:poll.5s="checkJobStatus">
@if ($jobStatus === 0)
<p>The import is in progress.</p>
<x-filament::loading-indicator class="h-10 w-10 text-primary-500" />
@elseif ($jobStatus === 1)
<p>The import is finished.</p>
@endif
</div>
And this is the component at app/livewire/PanImportProgress.php
namespace App\Livewire;

use Livewire\Component;
use App\Models\PanImport;

class PanImportProgress extends Component
{

public $record;
public $jobStatus;
public $panImport;

public function mount($record): void
{
$this->record = $record;
$this->jobStatus = 0;
$this->checkJobStatus();
}

public function checkJobStatus(): void
{
$this->panImport = PanImport::findOrFail($this->record);
$this->jobStatus = $this->panImport->status;
}


public function render()
{
return view('livewire.pan-import-progress', [
'jobStatus' => $this->jobStatus,
]);
}
}
namespace App\Livewire;

use Livewire\Component;
use App\Models\PanImport;

class PanImportProgress extends Component
{

public $record;
public $jobStatus;
public $panImport;

public function mount($record): void
{
$this->record = $record;
$this->jobStatus = 0;
$this->checkJobStatus();
}

public function checkJobStatus(): void
{
$this->panImport = PanImport::findOrFail($this->record);
$this->jobStatus = $this->panImport->status;
}


public function render()
{
return view('livewire.pan-import-progress', [
'jobStatus' => $this->jobStatus,
]);
}
}
Solution:
Solved: I wasn't passing the record into the livewire component.
Jump to solution
1 Reply
Solution
Douglas Gough
Douglas Gough7d ago
Solved: I wasn't passing the record into the livewire component.
Want results from more Discord servers?
Add your server