<?php

declare(strict_types=1);

namespace App\Models\Property;

use App\Models\Model;
use App\Models\User;

class Referral extends Model
{
    protected ?string $table = 'referrals';

    protected array $fillable = [
        'hashkey',
        'property_id',
        'referrer_id',
        'referred_id',
        'referred_name',
        'referred_contact',
        'status',
        'details',
        'is_active',
        'created_by',
        'updated_by',
    ];

    protected array $casts = [
        'details' => 'json',
        'is_active' => 'boolean',
    ];

    public function property()
    {
        return $this->belongsTo(Property::class, 'property_id');
    }

    public function referrer()
    {
        return $this->belongsTo(User::class, 'referrer_id');
    }

    public function referred()
    {
        return $this->belongsTo(User::class, 'referred_id');
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }
}
