<?php

namespace App\Models;

use App\Enums\AppRole;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class WorkspaceMember extends Model
{
    protected $fillable = [
        'workspace_id',
        'user_id',
        'role',
        'assists_influencer_user_id',
        'paired_restaurant_user_id',
    ];

    protected function casts(): array
    {
        return [
            'role' => AppRole::class,
        ];
    }

    public function workspace(): BelongsTo
    {
        return $this->belongsTo(Workspace::class);
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function assistsInfluencer(): BelongsTo
    {
        return $this->belongsTo(User::class, 'assists_influencer_user_id');
    }

    public function pairedRestaurant(): BelongsTo
    {
        return $this->belongsTo(User::class, 'paired_restaurant_user_id');
    }
}
