This commit is contained in:
2025-09-18 15:31:27 +02:00
commit 2abba0c2b7
406 changed files with 31879 additions and 0 deletions

108
app/Models/User.php Normal file
View File

@@ -0,0 +1,108 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Jakyeru\Larascord\Traits\InteractsWithDiscord;
use Laravelista\Comments\Commenter;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Support\Facades\DB;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, InteractsWithDiscord, Commenter;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'id',
'username',
'global_name',
'discriminator',
'email',
'avatar',
'verified',
'banner',
'banner_color',
'accent_color',
'locale',
'mfa_enabled',
'premium_type',
'public_flags',
'roles',
'is_banned',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'id' => 'integer',
'username' => 'string',
'global_name' => 'string',
'discriminator' => 'string',
'email' => 'string',
'avatar' => 'string',
'verified' => 'boolean',
'banner' => 'string',
'banner_color' => 'string',
'accent_color' => 'string',
'locale' => 'string',
'mfa_enabled' => 'boolean',
'premium_type' => 'integer',
'public_flags' => 'integer',
'roles' => 'json',
'tag_blacklist' => 'array',
];
/**
* Has Many Playlists.
*/
public function playlists(): HasMany
{
return $this->hasMany(Playlist::class);
}
/**
* Has Many Watched Episodes.
*/
public function watched(): HasMany
{
return $this->hasMany(Watched::class);
}
/**
* Has Many Watched Episodes.
*/
public function likes(): int
{
return DB::table('markable_likes')->where('user_id', $this->id)->count();
}
/**
* Has Many Comments.
*/
public function commentCount(): int
{
return DB::table('comments')->where('commenter_id', $this->id)->count();
}
}