<?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;

class User extends Authenticatable
{
    use HasFactory, Notifiable;

    protected $fillable = [
        'role_id',
        'kampus_id',
        'name',
        'email',
        'password',
    ];

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

    public function role()
    {
        return $this->belongsTo(Role::class);
    }

    public function kampus()
    {
        return $this->belongsTo(Kampus::class);
    }

    public function karyawan()
    {
        return $this->hasOne(Karyawan::class);
    }

    public function isMarketing()
    {
        return $this->role && $this->role->name === 'marketing';
    }

    public function isTelemarketing()
    {
        return $this->role && $this->role->name === 'telemarketing';
    }

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