Access properties on eagerly loaded relationships?

I don't know how to better approach this, any help appreciated. I have
protected function table(Table $table): Table
{
->query(Parent::latest()
->with(['relationship1', 'relationship2'])
)
protected function table(Table $table): Table
{
->query(Parent::latest()
->with(['relationship1', 'relationship2'])
)
I want (in this case Table EditAction, I'm okay with separate EditAction as well)
->actions([
EditAction::make('relationship1field')
->record($this->relationship1field)
->form([
TextInput::make('relationship1field'),
->actions([
EditAction::make('relationship1field')
->record($this->relationship1field)
->form([
TextInput::make('relationship1field'),
But I can't access relationship1field this way, what should I do? I can access $this->parentField and the field gets populated, but not $this->relationship1field or this->parent->relationship1field. I wonder if I need to separately save in a variable, but that would be n+1 query for something that already should be there and doesn't sit right with me (or maybe that's the actual best practice here so if anyone could enlighten me I'd appreciate it).
$memo = Parent::latest()->with(['relationship1', 'relationship2']);
$memo = Parent::latest()->with(['relationship1', 'relationship2']);
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server