Skip to content

Commit

Permalink
fix undefined key due to no candidate record
Browse files Browse the repository at this point in the history
  • Loading branch information
MarJose123 committed Jan 22, 2024
1 parent 42763df commit 429e606
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/Filament/Candidate/Pages/MyResumeProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Filament\Candidate\Pages;

use App\Models\Candidates;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Form;
Expand All @@ -26,17 +27,22 @@ class MyResumeProfile extends Page
public function mount(): void
{
$this->data = [
'Email' => $this->getResumeProfile()->count() === 0 ? auth()->user()->email : $this->getResumeProfile()->toArray()[0]['Email'],
...$this->getResumeProfile()->toArray()[0],
'Email' => $this->getResumeProfile()->count() === 0 ? Filament::auth()->user()->email : $this->getResumeProfile()->toArray()[0]['Email'],
];
if($this->getResumeProfile()->count() > 0)
{
$this->data = [
...$this->getResumeProfile()->toArray()[0],
];
}

$this->form->fill($this->data);
}

protected function getResumeProfile(): Collection
{
// Key matching using the login email address
return Candidates::where('Email', '=', auth()->user()->email)->get();
return Candidates::where('Email', '=', Filament::auth()->user()->email)->get();
}

public function updateRecord(): void
Expand Down

0 comments on commit 429e606

Please sign in to comment.