hasMany(PostImage::class, 'post_id', 'id'); } /** * @return mixed */ public function createdBy() { return $this->belongsTo(User::class, 'created_by', 'id'); } /** * @return mixed */ public function sanghDetails() { return $this->belongsTo(Sangh::class, 'type_id', 'id'); } /** * @return mixed */ public function updatedBy() { return $this->belongsTo(User::class, 'updated_by', 'id'); } /** * @return mixed */ public function likes() { return $this->belongsToMany(User::class, 'post_likes', 'post_id', 'user_id')->withTimestamps(); } /** * @return mixed */ public function tagUsers() { return $this->belongsToMany(User::class, 'post_tag_users', 'post_id', 'user_id')->withTimestamps(); } /** * @return mixed */ public function comments() { return $this->hasMany(PostComment::class, 'post_id', 'id')->whereNull('reply_id')->latest(); } /** * @return mixed */ public function category() { return $this->belongsTo(Category::class); } /** * @return mixed * for sangh post relationship with same naming convension for same response as other posts */ public function created_by() { return $this->belongsTo(Sangh::class, 'created_by', 'id'); } /** * @return mixed * for sangh post relationship with same naming convension for same response as other posts */ public function updated_by() { return $this->belongsTo(Sangh::class, 'updated_by', 'id'); } /** * @return mixed */ public function blockedUser() { return $this->hasMany(UserBlocked::class, 'user_id', 'user_id'); } /** * @return mixed */ public function hiddenPost() { return $this->hasMany(PostHidden::class, 'post_id', 'id'); } /** * @return mixed */ public function postMention() { return $this->hasMany(PostMention::class, 'post_id', 'id'); } }