<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;

class User extends Authenticatable
{
    use Notifiable;

    protected $table = 'creative_users'; // ← important!

    protected $fillable = [
        'first_name', 'last_name', 'email', 'password', 'role_id', 'status',
        // add other fields if needed (ref_employee_id, employee_id, etc.)
    ];

    protected $hidden = [
        'password', 'remember_token', 'created_at', 'updated_at',
    ];

    public function setPasswordAttribute($password)
    {
        $this->attributes['password'] = Hash::make($password);
    }

    public function role()
    {
        return $this->belongsTo(UserRoleMaster::class, 'role_id');
    }
}