コード例 #1
0
 /**
  * Return if the post is liked by the input user
  *
  * @return bool
  */
 public function isLiked()
 {
     if (!is_null($this->isLiked)) {
         return $this->isLiked;
     }
     if (!$this->object->likes->isEmpty()) {
         $this->object->likes->each(function ($like) {
             if ($like->user_id == $this->user->getPrimaryId()) {
                 return $this->isLiked = true;
             }
         });
     }
     if ($this->isLiked) {
         return true;
     }
     return $this->isLiked = false;
 }
コード例 #2
0
 /**
  * Check if the post is new to input user
  *
  * @return bool
  */
 public function isNew()
 {
     // Check if the user is seeing a post of another mb
     if ($this->object->user_id != $this->user->getPrimaryId()) {
         return false;
     }
     // Check if a isNew value is already stored
     if (!is_null($this->isNew)) {
         return $this->isNew;
     }
     // Confront the user lastView with the post child_datetime
     if (is_null($this->lastView)) {
         return $this->isNew = true;
     } elseif ($this->object->child_datetime > $this->user->mbLastView->datetime) {
         return $this->isNew = true;
     } else {
         return $this->isNew = false;
     }
 }
コード例 #3
0
 /**
  * Return input user page link for the view.
  *
  * @param  MbUserInterface  $user
  * @return string
  */
 protected function getUserLink(MbUserInterface $user)
 {
     return link_to_route($this->app['config']->get('ma_messageboard.user_named_route'), e($user->getUsername()), [$user->getPrimaryId()], []);
 }