Skip to content

[Bug]: 2nd level nested resources trying to find relationship in root level ancestor #48

@bardolf69

Description

@bardolf69

What happened?

When trying to add a 2nd level of nested resources I get a "Call to undefined method App\Models\Course::assessments()" error. My nesting is Course > Module > Assessment.

How to reproduce the bug

class CourseResource extends Resource
{
    use NestedResource;

    public static function getAncestor(): ?Ancestor
    {
        return null;
    }
class ModuleResource extends Resource
{
    use NestedResource;

    public static function getAncestor(): ?Ancestor
    {
        return Ancestor::make(
            'modules',
            'course',
        );
    }
class AssessmentResource extends Resource
{
    use NestedResource;

    public static function getAncestor(): ?Ancestor
    {
        return Ancestor::make(
            'assessments',
            'module',
        );
    }

Package Version

1.2.0

PHP Version

8.2.27

Laravel Version

11.44.1

Which operating systems does with happen with?

Linux

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions