src/Traits/Favoriteable.php
/**
     * Check if the user has favorited this Object
     * 
     * @param  int $user_id  [if  null its added to the auth user]
     * @return boolean
     */
Check if the user has favorited this Object

@param  int $user_id  [if  null its added to the auth user]
@return boolean
Check if the user has favorited this Object @param int $user_id [ if null its added to the auth user ] @return boolean
public function isFavorited($user_id = null)
    {
        if (!$this->relationLoaded('favorites')) {
            $this->load('favorites');
        }
        return (bool) $this->favorites
            ->where('user_id', $user_id ?: Auth::id())
            ->where('session_id', Session::getId())
            ->count();
    }
public function isFavorited ( $ user_id = null ) { if ( ! $ this -> relationLoaded ( 'favorites' ) ) { $ this -> load ( 'favorites' ) ; } return ( bool ) $ this -> favorites -> where ( 'user_id' , $ user_id ? : Auth :: id ( ) ) -> where ( 'session_id' , Session :: getId ( ) ) -> count ( ) ; }
Check if the user has favorited this Object
Check if the user has favorited this Object