<?php

namespace App\Models\Agency;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Permission\Models\Role;

class AgencyStaffInvitation extends Model
{
    use HasFactory;

    protected $fillable = [
        'agency_id',
        'email',
        'role_id',
        'position',
        'status',
        'token'
    ];

    public function agency()
    {
        return $this->belongsTo(Agency::class);
    }

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

    public function user()
    {
        // A user might not exist yet, or they might matching by email
        return $this->belongsTo(User::class, 'email', 'email');
    }
}
