Skip to content

Commit

Permalink
Merge pull request #4 from sald19/fix-get-logger-by-model
Browse files Browse the repository at this point in the history
fix get logger by model name or alias
  • Loading branch information
sald19 authored Jul 26, 2024
2 parents 3299c16 + 962699e commit d816f7f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Services/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Noxo\FilamentActivityLog\Services;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Noxo\FilamentActivityLog\Loggers\Logger;
use Noxo\FilamentActivityLog\Loggers\Loggers;
use UnitEnum;
Expand Down Expand Up @@ -31,6 +32,10 @@ public static function resolveLogger(null | string | Model $record, bool $force

$name = is_string($record) ? $record : get_class($record);

$name = is_string($record)
? (Relation::getMorphedModel($record) ?: $record)
: get_class($record);

return Loggers::getLoggerByModel($name, $force);
}

Expand Down

0 comments on commit d816f7f

Please sign in to comment.