diff options
Diffstat (limited to 'models/User.php')
-rw-r--r-- | models/User.php | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/models/User.php b/models/User.php index cacda49..6bfa423 100644 --- a/models/User.php +++ b/models/User.php @@ -10,7 +10,7 @@ use \lithium\security\Password; class User extends \lithium\data\Model { - public $hasMany = array('Post'); + public $hasMany = array('Post', 'Friends' => array('keys' => array('id' => 'ToUserId'))); public static function __init() { @@ -223,27 +223,12 @@ class User extends \lithium\data\Model { return $posts; } - /** - * Increments the amount profile views for the user. - * This is the command we are going to give to Mongo, which breaks down to db.users.update({_id : $id}, {$inc: {profileViews : 1}} ) - * Which says, find the user by their mongo ID, then increment their profile views by one. - * @param User $entity The instance of user to increment - * @param string $type Not implemented but in the future will allow you to increment anime manga and kdrama list views :TODO: - * @return null - */ - public function incrementViews($entity, $type = null) + public function myFriends($entity) { - if ($type = null) - { - $views = 'profileViews'; - } - $updateData = array('$inc' => array('profileViews' => 1)); - $conditions = array('_id' => $entity['_id']); - $result = User::update($updateData, $conditions, array('atomic' => false)); - return $result; + return self::find(array('conditions' => array('id' => $entity->friends->map(function ($f) { return $f->FromUserId;})))); + //return static::FindAllById($entity->friends->map(function ($f) { return $f->FromUserId; })); } - //Overrides save so we can do some stuff before the data is commited to the database. public function save($entity, $data = null, array $options = array()) { |