Files
Global-Jain/app/Models/Traits/Sangh/Relationships/SanghRelationships.php
2025-11-05 10:37:10 +05:30

92 lines
1.9 KiB
PHP

<?php
namespace App\Models\Traits\Sangh\Relationships;
use Carbon\Carbon;
use App\Models\Sant;
use App\Models\User;
use App\Models\Sangh;
use App\Models\Vihar;
use App\Models\Dharma;
use App\Models\Sampraday;
use App\Constant\Constant;
use App\Models\SantFollower;
use App\Models\SantRelation;
use App\Models\KarmaPointsTransaction;
/**
* Trait SanghRelationships
*
*/
trait SanghRelationships
{
/**
* @return mixed
*/
public function dharma()
{
return $this->belongsTo(Dharma::class, 'dharma_id');
}
/**
* @return mixed
*/
public function sampraday()
{
return $this->belongsTo(Sampraday::class, 'sampraday_id');
}
/**
* Get the sant followers.
*/
public function followers()
{
return $this->belongsToMany(User::class, 'sangh_followers', 'sangh_id', 'user_id')->withTimestamps();
}
/**
* Get the sant followings.
*/
public function followings()
{
return $this->belongsToMany(User::class, 'sangh_followers', 'user_id', 'sangh_id')->withTimestamps();
}
/**
* Get the sant followings.
*/
public function sanghMembers()
{
return $this->belongsToMany(User::class, 'sangh_members', 'sangh_id', 'user_id')->withTimestamps()->withPivot('core_committee', 'role', 'status', 'is_owner');
}
/**
* @return mixed
*/
public function createdBy()
{
return $this->belongsTo(User::class, 'created_by', 'id');
}
/**
* @return mixed
*/
public function updatedBy()
{
return $this->belongsTo(User::class, 'updated_by', 'id');
}
/**
* add points for for registration.
*/
public function addPoints()
{
return $this->morphMany(KarmaPointsTransaction::class, 'pointable');
}
public function user()
{
$this->belongsTo(User::class, 'user_id');
}
}