<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasFactory;
    use HasRoles;
    use Notifiable;

    protected $fillable = [
        'name',
        'email',
        'password',
        'discord_id',
        'discord_avatar',
        'fivem_license',
    ];

    protected $hidden = [
        'password',
        'remember_token',
        'two_factor_secret',
        'two_factor_recovery_codes',
    ];

    protected function casts(): array
    {
        return [
            'email_verified_at' => 'datetime',
            'two_factor_confirmed_at' => 'datetime',
            'password' => 'hashed',
        ];
    }

    // fivem_license: the FiveM Rockstar license this account is linked to,
    // set once the player links their in-game character via the /profile
    // linking flow. Nullable until linked — Discord-only accounts can
    // browse public pages and the news feed before ever linking a character.

    public function auditLogs()
    {
        return $this->hasMany(AuditLog::class);
    }

    public function rouletteDrops()
    {
        return $this->hasMany(RouletteDrop::class);
    }
}
