You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Article extends Moloquent
{
// this class has an attribute likeprotected$fillable = ['like'];
// and a static method likepublicstaticfunctionlike($article_id, $user_id) {
// ...$article = static::find($article_id);
$article->increment('like'); // here doesn't work
}
}
Jenssegers\Mongodb\Eloquent\Model;
line 125:
publicfunctiongetAttribute($key)
{
if (! $key) {
return;
}
// Dot notation support.if (str_contains($key, '.') andarray_has($this->attributes, $key)) {
return$this->getAttributeValue($key);
}
// This checks for embedded relation support.if (method_exists($this, $key) and ! method_exists(self::class, $key)) {
return$this->getRelationValue($key);
}
returnparent::getAttribute($key);
}
The problem is method_exists($this, $key) returns true and try to getRelationValue(), but Article::like() is a static method, so it will crash.
The text was updated successfully, but these errors were encountered:
I created a Model like this:
Jenssegers\Mongodb\Eloquent\Model;
line 125:
The problem is method_exists($this, $key) returns true and try to getRelationValue(), but Article::like() is a static method, so it will crash.
The text was updated successfully, but these errors were encountered: