<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable; // Para usar login
use Laravel\Sanctum\HasApiTokens; // Para tokens API
use Illuminate\Notifications\Notifiable;

class Postulante extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;

    protected $table = 'postulantes';

    protected $fillable = [
        'name',
        'email',
        'password',
        'dni',
        'device_id',
        'last_activity'
    ];


    protected $hidden = [
        'password',
        'device_id',
        'tokens'
    ];


    protected $casts = [
        'last_activity' => 'datetime',
    ];


    public function setPasswordAttribute($value)
    {
        $this->attributes['password'] = bcrypt($value);
    }
}
