<?php

namespace App\Support;

use App\Auth\XenForoUser;
use App\Models\LogXfUser;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Support\CauserResolver;

class XenForoCauserResolver extends CauserResolver
{
    public function getDefaultCauser(): ?Model
    {
        $user = \Auth::user();

        if( $user instanceof XenForoUser && $user->getAuthIdentifier() ){
            return LogXfUser::find($user->getAuthIdentifier());
        }

        return null;
    }
}
