"Call to a member function resume() on null" error from my test.

Forms\Components\Select::make('resume_id')
->label(__('translation.field.resume'))
->options(Auth::user()->resume()->pluck('name', 'id'))
->searchable(),
Forms\Components\Select::make('resume_id')
->label(__('translation.field.resume'))
->options(Auth::user()->resume()->pluck('name', 'id'))
->searchable(),
User.php
public function resume(): HasOne
{
return $this->hasOne(Resume::class);
}
public function resume(): HasOne
{
return $this->hasOne(Resume::class);
}
5 Replies
LeandroFerreira
Auth::user()->resume
Auth::user()->resume
What is it returning?
Shaung Bhone
Shaung BhoneOP2y ago
null
LeandroFerreira
that's it
Shaung Bhone
Shaung BhoneOP2y ago
but
Auth::user()->resume()
Auth::user()->resume()
<-- it is working. In testing, give me null. All fine on the browser.
->options(Auth::user()?->resume()->pluck('name', 'id'))
->options(Auth::user()?->resume()->pluck('name', 'id'))
it's working with above code in the testing. I don't understand
Dennis Koch
Dennis Koch2y ago
So you don't have a user logged in in your test?
Want results from more Discord servers?
Add your server