Вопрос

In Laravel 4, is there a method that allows you to test for a relationship between two Eloquent objects without knowing the type of relationship beforehand?

For example, a user model would have a 1:1 relation with a profile and a 1:m relation with comments. I'm looking for some way to do something along the lines of the following:

if ($user->isRelatedTo($someOtherObject))
{
    // stuff
}
Это было полезно?

Решение

Unfortunately there is not, relations are not managed in config files thus it is impossible to test. You could however make these config files yourself and extend Eloquent to implement this method.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top