Files
Global-Jain/app/Models/Traits/User/Relationships/UserRelationships.php

200 lines
4.5 KiB
PHP
Raw Normal View History

2025-11-05 10:37:10 +05:30
<?php
namespace App\Models\Traits\User\Relationships;
use App\Constant\Constant;
use App\Models\Jati;
use App\Models\User;
use App\Models\Dharma;
use App\Models\KarmaPointsTransaction;
use App\Models\MessagesThreads;
use App\Models\Request;
use App\Models\Sangh;
use App\Models\Sant;
use App\Models\UserBlocked;
/**
* Trait UserRelationships
* @package Domains\User\Models\Traits\Relationships
*/
trait UserRelationships
{
/**
* @return mixed
*/
public function userMetas()
{
return $this->hasMany(\App\Models\UserMeta::class);
}
/**
* @return mixed
*/
public function userDeviceTokens()
{
return $this->hasMany(\App\Models\UserDeviceToken::class);
}
/**
* @return mixed
*/
public function userSocialLogins()
{
return $this->hasMany(\App\Models\UserSocialLogin::class);
}
/**
* @return mixed
*/
public function userDetail()
{
return $this->hasMany(\App\Models\UserDetail::class);
}
/**
* @return mixed
*/
public function userWorkDetail()
{
return $this->hasMany(\App\Models\UserWorkDetail::class)->orderBy('updated_at', 'DESC')->orderBy('start_year', 'DESC');
}
/**
* @return mixed
*/
public function userQualification()
{
return $this->hasMany(\App\Models\UserQualification::class);
}
/**
* @return mixed
*/
public function userRelationshipRequests()
{
return $this->hasMany(\App\Models\UserRelation::class, 'from_id');
}
/**
* @return mixed
*/
public function colleges()
{
return $this->hasMany(\App\Models\UserQualification::class)->where('type', Constant::STATUS_ONE);
}
/**
* @return mixed
*/
public function schools()
{
return $this->hasMany(\App\Models\UserQualification::class)->where('type', Constant::STATUS_TWO);
}
/**
* @return mixed
*/
public function friendRequests()
{
return $this->belongsToMany(User::class, 'requests', 'sender_id', 'receiver_id')->withTimestamps()->withPivot('status');
}
/**
* @return mixed
*/
public function myFriendRequests()
{
return $this->belongsToMany(User::class, 'requests', 'receiver_id', 'sender_id')->withTimestamps()->withPivot('status');
}
/**
* @return mixed
*/
public function dharma()
{
return $this->belongsTo(Dharma::class);
}
/**
* Get the sant followers.
*/
public function followers()
{
return $this->belongsToMany(User::class, 'sant_followers', 'sant_id', 'user_id')->withTimestamps();
}
/**
* Get the sant followings.
*/
public function followings()
{
return $this->belongsToMany(Sant::class, 'sant_followers', 'user_id', 'sant_id')->where('status', Constant::STATUS_TWO)->withTimestamps();
}
/**
* Get the sant followers.
*/
public function sanghFollowers()
{
return $this->belongsToMany(User::class, 'sangh_followers', 'sangh_id', 'user_id')->withTimestamps();
}
/**
* Get the sant followings.
*/
public function sanghFollowings()
{
return $this->belongsToMany(Sangh::class, 'sangh_followers', 'user_id', 'sangh_id')->withTimestamps();
}
/**
* Get the user passive user (child).
*/
public function passiveUser()
{
return $this->hasMany(User::class, 'parent_id')->where('is_passive', Constant::STATUS_ONE);
}
/**
* Get the sant followings.
*/
public function sanghMembers()
{
return $this->belongsToMany(Sangh::class, 'sangh_members', 'user_id', 'sangh_id')->where('status', 1)->withTimestamps()->withPivot('core_committee', 'role');
}
/**
* add points for for registration.
*/
public function addPoints()
{
return $this->morphMany(KarmaPointsTransaction::class, 'pointable');
}
/**
* Get the sant followings.
*/
public function sentMessageThread()
{
return $this->hasMany(MessagesThreads::class, 'sender_id');
}
/**
* Get the sant followings.
*/
public function receivedMessageThread()
{
return $this->hasMany(MessagesThreads::class, 'receiver_id');
// return $this->belongsToMany(User::class, 'message_threads', 'receiver_id', 'sender_id')->withTimestamps();
}
/**
* Get the sant followings.
*/
public function blockedUser()
{
return $this->hasMany(UserBlocked::class, 'user_id');
}
}