itsgoingd / clockwork

Clockwork - php dev tools in your browser - server-side component
https://underground.works/clockwork
MIT License
5.69k stars 321 forks source link

Skip accessing `$name` property when `name()` method exists #596

Closed devfrey closed 2 years ago

devfrey commented 2 years ago

Consider the following model:

class User extends Model
{
    public function name()
    {
        return $this->first_name . ' ' . $this->last_name;
    }
}

When Clockwork tries to collect information about this user, it accesses the $name property. Laravel assumes you're trying to call the name relationship defined in the name() method (which isn't a relationship in this example). It then throws a LogicException: "Model::name must return a relationship instance.".

By checking the user() method doesn't exist this exception can be avoided.

itsgoingd commented 2 years ago

Sounds good, thanks!

devfrey commented 2 years ago

@itsgoingd Is there any chance you could tag a patch release for this?

itsgoingd commented 2 years ago

Hey, thanks for reminder, completely forgot about this. I have one more thing I would like to do before release, I'll try to get this out later this week. Feel free to remind me again if that doesn't happen. 😅

itsgoingd commented 2 years ago

Tagged 5.1.8 incl this fix, thanks!