class Article extends Moloquent
{
// this class has an attribute like
protected $fillable = ['like'];
// and a static method like
public static function like($article_id, $user_id) {
// ...
$article = static::find($article_id);
$article->increment('like'); // here doesn't work
}
}
Jenssegers\Mongodb\Eloquent\Model;
line 125:
public function getAttribute($key)
{
if (! $key) {
return;
}
// Dot notation support.
if (str_contains($key, '.') and array_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);
}
return parent::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.
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.