mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-31 05:16:49 -04:00
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\MLMDownline\Entities;
|
|
|
|
use App\Models\Staff;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Modules\RolePermission\Entities\Permission;
|
|
use Modules\RolePermission\Entities\Role;
|
|
use Modules\StudioPlus\Entities\StudioPlusChannel;
|
|
use Modules\StudioPlus\Entities\StudioPlusVideo;
|
|
|
|
class MLMDownlineUser extends User
|
|
{
|
|
protected $table = 'users';
|
|
|
|
protected $appends = [
|
|
'full_name'
|
|
];
|
|
|
|
public const ROLE_TYPE_VIDEO_MANAGER = 'vm';
|
|
public const ROLE_TYPE_CREATOR_MANAGER = 'cm';
|
|
public const ROLE_TYPE_VIDEO_CREATOR_MANAGER = 'vcm';
|
|
public const ROLE_TYPE_VIDEO_CREATOR = 'vc';
|
|
|
|
public function upline()
|
|
{
|
|
return $this->belongsTo(self::class, 'parent_id', 'id');
|
|
}
|
|
|
|
public function downline()
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id', 'id');
|
|
}
|
|
|
|
public function role()
|
|
{
|
|
return $this->belongsTo(Role::class);
|
|
}
|
|
|
|
public function staff()
|
|
{
|
|
return $this->hasOne(Staff::class, 'user_id', 'id');
|
|
}
|
|
|
|
public function videos()
|
|
{
|
|
return $this->hasManyThrough(StudioPlusVideo::class, StudioPlusChannel::class, 'user_id', 'studio_plus_channel_id');
|
|
}
|
|
|
|
public function getFullNameAttribute()
|
|
{
|
|
return strtoupper("{$this->first_name} {$this->last_name}");
|
|
}
|
|
}
|