<?php

namespace App\Models;

use App\Notifications\PasswordReset;
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class SubDealer extends Authenticatable
{
    use HasFactory, Notifiable;

    protected $table = "sub_dealers";

//    protected $guarded = "sub-master-dealer";

    protected $fillable = [
        'sub_dealer_id',
        'master_dealer_id',
        'company_name',
        'contact_person',
        'contact_number',
        'email',
        'password',
        'state',
        'total_license',
        'used_license',
        'status',
    ];


    protected $hidden = [
        'password',
    ];

    public function masterDealer(): BelongsTo
    {
        return $this->belongsTo(MasterDealer::class, 'master_dealer_id', 'master_dealer_id');
    }

    public function sendPasswordResetNotification($token): void
    {
        $token = $token.'-03';
        $this->notify(new PasswordReset($token));
    }
}
