owen-it /
laravel-auditing
| 1 | <?php |
||
| 2 | |||
| 3 | namespace OwenIt\Auditing\Resolvers; |
||
| 4 | |||
| 5 | use Illuminate\Support\Facades\App; |
||
| 6 | use Illuminate\Support\Facades\Request; |
||
| 7 | use OwenIt\Auditing\Contracts\Auditable; |
||
| 8 | use OwenIt\Auditing\Contracts\Resolver; |
||
| 9 | |||
| 10 | class UrlResolver implements Resolver |
||
| 11 | { |
||
| 12 | public static function resolve(Auditable $auditable): string |
||
| 13 | { |
||
| 14 | 15 | if (! empty($auditable->preloadedResolverData['url'] ?? null)) { |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 15 | return $auditable->preloadedResolverData['url'] ?? ''; |
||
| 16 | 15 | } |
|
| 17 | 15 | ||
| 18 | if (App::runningInConsole()) { |
||
| 19 | return self::resolveCommandLine(); |
||
| 20 | 15 | } |
|
| 21 | 13 | ||
| 22 | return Request::fullUrl(); |
||
| 23 | } |
||
| 24 | 2 | ||
| 25 | public static function resolveCommandLine(): string |
||
| 26 | { |
||
| 27 | 13 | $command = Request::server('argv', null); |
|
| 28 | if (is_array($command)) { |
||
| 29 | 13 | return implode(' ', $command); |
|
| 30 | 13 | } |
|
| 31 | 13 | ||
| 32 | return 'console'; |
||
| 33 | } |
||
| 34 | } |
||
| 35 |