Skip to content

Commit 8983b0f

Browse files
committed
Add user id field to the config
1 parent 1f83793 commit 8983b0f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LARAVEL_LOGGER_ROLE_MODEL=jeremykenedy\LaravelRoles\Models\Role
66
LARAVEL_LOGGER_MIDDLEWARE_ENABLED=true
77
LARAVEL_LOGGER_MIDDLEWARE_EXCEPT=ignore1pattern1,ignorepattern2
88
LARAVEL_LOGGER_USER_MODEL=App\Models\User
9+
LARAVEL_LOGGER_USER_ID_FIELD=id
910
LARAVEL_LOGGER_DISABLE_ROUTES=false
1011
LARAVEL_LOGGER_PAGINATION_ENABLED=true
1112
LARAVEL_LOGGER_PAGINATION_PER_PAGE=25

src/app/Http/Traits/ActivityLogger.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public static function activity($description = null)
2424

2525
if (\Auth::check()) {
2626
$userType = trans('LaravelLogger::laravel-logger.userTypes.registered');
27-
$userId = Request::user()->id;
27+
$userIdField = config('LaravelLogger.defaultUserIDField');
28+
$userId = Request::user()->{$userIdField};
2829
}
2930

3031
if (Crawler::isCrawler()) {

src/config/laravel-logger.php

+8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565

6666
'defaultUserModel' => env('LARAVEL_LOGGER_USER_MODEL', 'App\User'),
6767

68+
/*
69+
|--------------------------------------------------------------------------
70+
| Laravel Default User ID Field
71+
|--------------------------------------------------------------------------
72+
*/
73+
74+
'defaultUserIDField' => env('LARAVEL_LOGGER_USER_ID_FIELD', 'id'),
75+
6876
/*
6977
|--------------------------------------------------------------------------
7078
| Disable automatic Laravel Logger routes

0 commit comments

Comments
 (0)