[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: CauserResolver.php
<?php namespace Spatie\Activitylog; use Closure; use Illuminate\Auth\AuthManager; use Illuminate\Contracts\Config\Repository; use Illuminate\Database\Eloquent\Model; use Spatie\Activitylog\Exceptions\CouldNotLogActivity; class CauserResolver { protected AuthManager $authManager; protected string | null $authDriver; protected Closure | null $resolverOverride = null; protected Model | null $causerOverride = null; public function __construct(Repository $config, AuthManager $authManager) { $this->authManager = $authManager; $this->authDriver = $config['activitylog']['default_auth_driver']; } public function resolve(Model | int | string | null $subject = null): ?Model { if ($this->causerOverride !== null) { return $this->causerOverride; } if ($this->resolverOverride !== null) { $resultCauser = ($this->resolverOverride)($subject); if (! $this->isResolvable($resultCauser)) { throw CouldNotLogActivity::couldNotDetermineUser($resultCauser); } return $resultCauser; } return $this->getCauser($subject); } protected function resolveUsingId(int | string $subject): Model { $guard = $this->authManager->guard($this->authDriver); $provider = method_exists($guard, 'getProvider') ? $guard->getProvider() : null; $model = method_exists($provider, 'retrieveById') ? $provider->retrieveById($subject) : null; throw_unless($model instanceof Model, CouldNotLogActivity::couldNotDetermineUser($subject)); return $model; } protected function getCauser(Model | int | string | null $subject = null): ?Model { if ($subject instanceof Model) { return $subject; } if (is_null($subject)) { return $this->getDefaultCauser(); } return $this->resolveUsingId($subject); } /** * Override the resover using callback. */ public function resolveUsing(Closure $callback): static { $this->resolverOverride = $callback; return $this; } /** * Override default causer. */ public function setCauser(?Model $causer): static { $this->causerOverride = $causer; return $this; } protected function isResolvable(mixed $model): bool { return $model instanceof Model || is_null($model); } protected function getDefaultCauser(): ?Model { return $this->authManager->guard($this->authDriver)->user(); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285