loggedInUser()->id, 'sender_id' => $this->created_by, 'status' => Constant::STATUS_ONE ])->first(); $sender = Request::where([ 'receiver_id' => $this->created_by, 'sender_id' => loggedInUser()->id, 'status' => Constant::STATUS_ONE ])->first(); if ($receiver || $sender) { return Constant::STATUS_TRUE; } else { return Constant::STATUS_FALSE; } } /** * Returns user's liked status. */ public function getIsLikedAttribute() { $user = loggedInUser(); if ($this->likes->contains($user->id)) { return Constant::STATUS_TRUE; } else { return Constant::STATUS_FALSE; } } /** * Returns user's liked status. */ public function getPostTypeAttribute() { if ($this->category_id == Constant::STATUS_ONE) { return 'Dharmik'; } else if ($this->category_id == Constant::STATUS_TWO) { return 'Accomplishment'; } else if ($this->category_id == Constant::STATUS_THREE) { return 'Announcement'; } else if ($this->category_id == Constant::STATUS_FOUR) { return 'Celebration'; } else if ($this->category_id == Constant::STATUS_FIVE) { return 'General'; } } /** * Returns post's mentions. */ public function getMentionsAttribute() { $postMentions = PostMention::where('post_id', $this->id)->get()->toArray(); $data = []; foreach ($postMentions as $postMention) { if (!empty($postMention) && $postMention['type'] == Constant::STATUS_ONE) { $user = User::where('id', $postMention['mention_id'])->first(); $data[] = [ 'id' => $user->id, 'name' => $user->name, 'type' => 'user' ]; } if (!empty($postMention) && $postMention['type'] == Constant::STATUS_TWO) { $sant = Sant::where('id', $postMention['mention_id'])->first(); $data[] = [ 'id' => $sant->id, 'name' => $sant->name, 'type' => 'sant' ]; } if (!empty($postMention) && $postMention['type'] == Constant::STATUS_THREE) { $sangh = Sangh::where('id', $postMention['mention_id'])->first(); $data[] = [ 'id' => $sangh->id, 'name' => $sangh->name, 'type' => 'sangh' ]; } } return $data; } }