<?php

namespace App\Models\Auth;

use Illuminate\Database\Eloquent\Model;

class UserAlt extends Model
{
    public $table = 'user_alts';

    public $primaryKey = 'id';

    public $timestamps = false;

    /**
     * The attributes that are mass assignable
     * 
     * @var array
     */
    protected $fillable = [
        'name',
        'main_id',
        'character_id',
        'avatar',
        'access_token',
        'inserted_at',
        'expires_in',
        'owner_hash',
    ];

    public function mainCharacter() {
        return $this->belongsTo('App\Models\Auth\User', 'character_id', 'main_id');
    }

    public function getMain() {
        return User::where([
            'character_id' => $this->main_id
        ])->get();
    }
}
