<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Salesman extends Model
{
    use HasFactory;

    protected $table = 'salesmen';
    protected $guarded = [];

    /**
     * Relasi ke akun User (Data Login Salesman)
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    /**
     * Relasi ke akun Supervisor (Atasan Salesman)
     * Menggunakan supervisor_id yang merujuk ke tabel users
     */
    public function supervisor(): BelongsTo
    {
        return $this->belongsTo(User::class, 'supervisor_id');
    }
}