kirkbushell / eloquence

A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.
MIT License
537 stars 60 forks source link

v11 dynamic relation property not working #114

Closed JustinElst closed 2 months ago

JustinElst commented 4 months ago

Hi, Thanks for all your great work.

I have upgraded eloquence to V11 but now I get the following message:

The attribute [relation_name] either does not exist or was not retrieved for model

I am trying to access the relation like so: $model->relationName->attributeValueOfRelation In the model I have this relationship definition:

class Model extends LaravelModel
{
    use HasCamelCasing;

    public function relationName(): BelongsTo
    {
        return $this->belongsTo(RelationModel::class);
    }
}

If I revert this commit, everything works as expected: https://github.com/kirkbushell/eloquence/commit/15b885252a1628cbc4ba0f31015329143ab42018

What am I overlooking, the documentation/changelog doesn't mention anything about relationships or its definition...

kirkbushell commented 2 months ago

@JustinElst Sorry for slow response, not sure why I'm not getting notifications here.

Yeah, I see the issue - relationships aren't being picked up via snake_case.

Should be fixed now in 11.0.2