ChristianKuri / laravel-favorite

Allows Laravel Eloquent models to implement a 'favorite', 'like', 'remember' and 'follow' features.
MIT License
226 stars 48 forks source link

How to check whether user already favourite an object? #4

Closed od3n closed 7 years ago

ghost commented 7 years ago

Into your Model:

/**
 * Check if the user has favorited this Object
 * The Model needs to have the Favoriteable trai
 * 
 * @param Object $object
 * @return boolean
 */
public function hasFavorited($object)
{
    return $object->isFavorited($this->id);
}
od3n commented 7 years ago

Thank you