public function getUnreadMessagesCount($uid)
	{
		if (!$uid)
		{
			return 0;
		}

		$r = $this->getTableName();
		$m = Message::blank()->getTableName();
		$s = Seen::blank()->getTableName();

		$entries = Message::blank()
			->join($r, $m . '.id', $r . '.mid', 'inner')
			->whereEquals($r . '.uid', $uid)
			->where($r . '.state', '!=', 2)
			->whereRaw($m . ".id NOT IN (SELECT s.mid FROM `" . $s . "` AS s WHERE s.uid=" . $uid . ")");

		return $entries->total();
	}
public function getUnreadMessagesCount($uid)
	{
		if (!$uid)
		{
			return 0;
		}

		$r = $this->getTableName();
		$m = Message::blank()->getTableName();
		$s = Seen::blank()->getTableName();

		$entries = Message::blank()
			->join($r, $m . '.id', $r . '.mid', 'inner')
			->whereEquals($r . '.uid', $uid)
			->where($r . '.state', '!=', 2)
			->whereRaw($m . ".id NOT IN (SELECT s.mid FROM `" . $s . "` AS s WHERE s.uid=" . $uid . ")");

		return $entries->total();
	}
public function getUnreadMessagesCount ( $ uid ) { if ( ! $ uid ) { return 0 ; } $ r = $ this -> getTableName ( ) ; $ m = Message :: blank ( ) -> getTableName ( ) ; $ s = Seen :: blank ( ) -> getTableName ( ) ; $ entries = Message :: blank ( ) -> join ( $ r , $ m . '.id' , $ r . '.mid' , 'inner' ) -> whereEquals ( $ r . '.uid' , $ uid ) -> where ( $ r . '.state' , '!=' , 2 ) -> whereRaw ( $ m . ".id NOT IN (SELECT s.mid FROM `" . $ s . "` AS s WHERE s.uid=" . $ uid . ")" ) ; return $ entries -> total ( ) ; }
Get a count of unread messages for a user

@param   integer  $uid    User ID
@return  integer
Get a count of unread messages for a user