belongsTo(Staff::class, 'id', 'user_id'); } public function channel() { return $this->hasOne(StudioPlusChannel::class, 'user_id', 'id'); } public function videos() { return $this->hasManyThrough( StudioPlusVideo::class, StudioPlusChannel::class, 'user_id', 'studio_plus_channel_id' ); } public function getFullNameAttribute() { return "{$this->first_name} {$this->last_name}"; } public function downline() { return $this->hasMany(self::class, 'parent_id', 'id'); } public function downlines() { return $this->hasMany(self::class, 'parent_id', 'id'); } public function getIsVcOrVcmAttribute() { if (!permissionCheck('studio-plus.can_view_all_videos') && permissionCheck('downline') && permissionCheck('studio-plus.can_upload_video')) { return true; } return false; } public function getTotalVideosForTheMonthAttribute() { $current_month = Carbon::now()->month; $current_year = Carbon::now()->year; $start_date = Carbon::create($current_year, $current_month, 1)->startOfDay(); $end_date = $start_date->copy()->endOfMonth(); return $this->videos()->whereBetween('studio_plus_videos.created_at', [$start_date, $end_date])->get()->count(); } public function getActiveAttribute() { $min_date = Carbon::now()->subMonths(2); $videos = $this->videos()->where('studio_plus_videos.created_at', '>', $min_date)->get(); return $videos->count() > 0; } }