public function podiumThumb($up = true, $count = 0)
    {
        $transaction = static::getDb()->beginTransaction();
        try {
            $loggedId = User::loggedId();
            if ($this->thumb) {
                if ($this->thumb->thumb == 1 && !$up) {
                    $this->thumb->thumb = -1;
                    if (!$this->thumb->save()) {
                        throw new Exception('Thumb saving error!');
                    }
                    if (!$this->updateCounters(['likes' => -1, 'dislikes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                } elseif ($this->thumb->thumb == -1 && $up) {
                    $this->thumb->thumb = 1;
                    if (!$this->thumb->save()) {
                        throw new Exception('Thumb saving error!');
                    }
                    if (!$this->updateCounters(['likes' => 1, 'dislikes' => -1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                }
            } else {
                $postThumb = new PostThumb();
                $postThumb->post_id = $this->id;
                $postThumb->user_id = $loggedId;
                $postThumb->thumb = $up ? 1 : -1;
                if (!$postThumb->save()) {
                    throw new Exception('PostThumb saving error!');
                }
                if ($postThumb->thumb) {
                    if (!$this->updateCounters(['likes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                } else {
                    if (!$this->updateCounters(['dislikes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                }
            }
            if ($count == 0) {
                Podium::getInstance()->podiumCache->set('user.votes.' . $loggedId, ['count' => 1, 'expire' => time() + 3600]);
            } else {
                Podium::getInstance()->podiumCache->setElement('user.votes.' . $loggedId, 'count', $count + 1);
            }
            $transaction->commit();
            return true;
        } catch (Exception $e) {
            $transaction->rollBack();
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
public function podiumThumb($up = true, $count = 0)
    {
        $transaction = static::getDb()->beginTransaction();
        try {
            $loggedId = User::loggedId();
            if ($this->thumb) {
                if ($this->thumb->thumb == 1 && !$up) {
                    $this->thumb->thumb = -1;
                    if (!$this->thumb->save()) {
                        throw new Exception('Thumb saving error!');
                    }
                    if (!$this->updateCounters(['likes' => -1, 'dislikes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                } elseif ($this->thumb->thumb == -1 && $up) {
                    $this->thumb->thumb = 1;
                    if (!$this->thumb->save()) {
                        throw new Exception('Thumb saving error!');
                    }
                    if (!$this->updateCounters(['likes' => 1, 'dislikes' => -1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                }
            } else {
                $postThumb = new PostThumb();
                $postThumb->post_id = $this->id;
                $postThumb->user_id = $loggedId;
                $postThumb->thumb = $up ? 1 : -1;
                if (!$postThumb->save()) {
                    throw new Exception('PostThumb saving error!');
                }
                if ($postThumb->thumb) {
                    if (!$this->updateCounters(['likes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                } else {
                    if (!$this->updateCounters(['dislikes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                }
            }
            if ($count == 0) {
                Podium::getInstance()->podiumCache->set('user.votes.' . $loggedId, ['count' => 1, 'expire' => time() + 3600]);
            } else {
                Podium::getInstance()->podiumCache->setElement('user.votes.' . $loggedId, 'count', $count + 1);
            }
            $transaction->commit();
            return true;
        } catch (Exception $e) {
            $transaction->rollBack();
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
public function podiumThumb ( $ up = true , $ count = 0 ) { $ transaction = static :: getDb ( ) -> beginTransaction ( ) ; try { $ loggedId = User :: loggedId ( ) ; if ( $ this -> thumb ) { if ( $ this -> thumb -> thumb == 1 && ! $ up ) { $ this -> thumb -> thumb = - 1 ; if ( ! $ this -> thumb -> save ( ) ) { throw new Exception ( 'Thumb saving error!' ) ; } if ( ! $ this -> updateCounters ( [ 'likes' => - 1 , 'dislikes' => 1 ] ) ) { throw new Exception ( 'Thumb counters saving error!' ) ; } } elseif ( $ this -> thumb -> thumb == - 1 && $ up ) { $ this -> thumb -> thumb = 1 ; if ( ! $ this -> thumb -> save ( ) ) { throw new Exception ( 'Thumb saving error!' ) ; } if ( ! $ this -> updateCounters ( [ 'likes' => 1 , 'dislikes' => - 1 ] ) ) { throw new Exception ( 'Thumb counters saving error!' ) ; } } } else { $ postThumb = new PostThumb ( ) ; $ postThumb -> post_id = $ this -> id ; $ postThumb -> user_id = $ loggedId ; $ postThumb -> thumb = $ up ? 1 : - 1 ; if ( ! $ postThumb -> save ( ) ) { throw new Exception ( 'PostThumb saving error!' ) ; } if ( $ postThumb -> thumb ) { if ( ! $ this -> updateCounters ( [ 'likes' => 1 ] ) ) { throw new Exception ( 'Thumb counters saving error!' ) ; } } else { if ( ! $ this -> updateCounters ( [ 'dislikes' => 1 ] ) ) { throw new Exception ( 'Thumb counters saving error!' ) ; } } } if ( $ count == 0 ) { Podium :: getInstance ( ) -> podiumCache -> set ( 'user.votes.' . $ loggedId , [ 'count' => 1 , 'expire' => time ( ) + 3600 ] ) ; } else { Podium :: getInstance ( ) -> podiumCache -> setElement ( 'user.votes.' . $ loggedId , 'count' , $ count + 1 ) ; } $ transaction -> commit ( ) ; return true ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Performs vote processing.
@param bool $up whether this is upvote
@param int $count number of user cached votes
@return bool
@since 0.2
Performs vote processing .