public function getUnreadMessages($uid, $limit=null)
	{
		if (!$uid)
		{
			return array();
		}

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

		$entries = Message::all()
			->select($m . '.*,' . $r . '.expires,' . $r . '.actionid')
			//->join($m, $m . '.id', $r . '.mid', 'inner')
			->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 . ")")
			->order($r . '.created', 'desc');

		if ($limit)
		{
			$entries->limit($limit);
		}

		return $entries->rows();
	}