Skip to content

Resource whenPivotLoaded not showing relation #14

@Wanjiaa

Description

@Wanjiaa

How can I add this relation to my resource to only show it when it's loaded?

I have this pivot between Module And File with an added language_id to this pivot

'pivot' => $this->whenPivotLoaded('module_file', fn () => [
    'sequence'      => $this->pivot->sequence,
    'language_id'   => $this->pivot->language_id,
    'language_code' => $this->whenLoaded('language', $this->pivot->language->code), // Doesn't show
    'language_code' => $this->pivot->whenLoaded('language', $this->pivot->language->code), // Error
    'language_code' => $this->whenPivotLoaded('language', $this->pivot->language->code), // Doesn't show
]),

The Language relation doesnt even show when I just use

'pivot' => $this->whenPivotLoaded('module_file', $this->pivot),
'pivot' => $this->whenPivotLoaded('module_file', fn () => $this->pivot),

How would this work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions