<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use HasFactory, Notifiable;

    const ROLE_MEMBER = 0;
    const ROLE_ADMIN = 1;

    const STATUS_INACTIVE = 0;
    const STATUS_ACTIVE = 1;

    const FLAG_SEND_DISABLED = 0;
    const FLAG_SEND_ENABLED = 1;

    const FIRST_LOGIN_FALSE = 0;
    const FIRST_LOGIN_TRUE = 1;


    protected $table = 'user';
    public $timestamps = false;
    protected $primaryKey = 'id';

    protected $fillable = [
        'msnv',
        'name',
        'mail',
        'pass',
        'departments',
        'avatar',
        'role',
        'status',
        'card',
        'flag_send',
        'first_login',
    ];

    protected $hidden = [
        'pass',
    ];

    /**
     * Get the password for the user.
     *
     * @return string
     */
    public function getAuthPassword()
    {
        return $this->pass;
    }

    // Disable remember token support in database
    public function getRememberToken()
    {
        return null;
    }

    public function setRememberToken($value)
    {
    }

    public function getRememberTokenName()
    {
        return '';
    }

    public function transactions()
    {
        return $this->hasMany(Administration::class, 'msnv', 'msnv');
    }

    public function cardPurchases()
    {
        return $this->hasMany(AddCard::class, 'buyer', 'msnv');
    }
}
