File tree Expand file tree Collapse file tree 8 files changed +41
-11
lines changed Expand file tree Collapse file tree 8 files changed +41
-11
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ Laravel logger is an activity event logger for your Laravel or Lumen application
39
39
| Routing Events can recording using middleware|
40
40
| Records activity timestamps|
41
41
| Records activity description|
42
+ | Records activity details (optional)|
42
43
| Records activity user type with crawler detection.|
43
44
| Records activity Method|
44
45
| Records activity Route|
@@ -216,20 +217,25 @@ When using the trait you can customize the event description.
216
217
To use the trait:
217
218
1 . Include the call in the head of your class file:
218
219
219
- ``` php
220
- use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
221
- ```
220
+ ``` php
221
+ use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
222
+ ```
222
223
223
224
2. Include the trait call in the opening of your class:
224
225
225
- ``` php
226
- use ActivityLogger;
227
- ```
226
+ ```php
227
+ use ActivityLogger;
228
+ ```
228
229
229
230
3. You can record the activity my calling the traits method:
230
- ```
231
- ActivityLogger::activity("Logging this activity.");
232
- ```
231
+ ```
232
+ ActivityLogger::activity("Logging this activity.");
233
+ ```
234
+
235
+ Or as bellow to include extended activity details:
236
+ ```
237
+ ActivityLogger::activity("Logging this activity.", "Additional activity details.");
238
+ ```
233
239
234
240
### Routes
235
241
##### Laravel Activity Dashbaord Routes
Original file line number Diff line number Diff line change @@ -14,11 +14,12 @@ trait ActivityLogger
14
14
/**
15
15
* Laravel Logger Log Activity.
16
16
*
17
- * @param string $description
17
+ * @param null $description
18
+ * @param null $details
18
19
*
19
20
* @return void
20
21
*/
21
- public static function activity ($ description = null )
22
+ public static function activity ($ description = null , $ details = null )
22
23
{
23
24
$ userType = trans ('LaravelLogger::laravel-logger.userTypes.guest ' );
24
25
$ userId = null ;
@@ -62,6 +63,7 @@ public static function activity($description = null)
62
63
63
64
$ data = [
64
65
'description ' => $ description ,
66
+ 'details ' => $ details ,
65
67
'userType ' => $ userType ,
66
68
'userId ' => $ userId ,
67
69
'route ' => Request::fullUrl (),
@@ -95,6 +97,7 @@ private static function storeActivity($data)
95
97
{
96
98
Activity::create ([
97
99
'description ' => $ data ['description ' ],
100
+ 'details ' => $ data ['details ' ],
98
101
'userType ' => $ data ['userType ' ],
99
102
'userId ' => $ data ['userId ' ],
100
103
'route ' => $ data ['route ' ],
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ class Activity extends Model
57
57
*/
58
58
protected $ fillable = [
59
59
'description ' ,
60
+ 'details ' ,
60
61
'userType ' ,
61
62
'userId ' ,
62
63
'route ' ,
@@ -69,6 +70,7 @@ class Activity extends Model
69
70
70
71
protected $ casts = [
71
72
'description ' => 'string ' ,
73
+ 'details ' => 'string ' ,
72
74
'user ' => 'integer ' ,
73
75
'route ' => 'string ' ,
74
76
'ipAddress ' => 'string ' ,
@@ -134,6 +136,7 @@ public static function rules($merge = [])
134
136
return array_merge (
135
137
[
136
138
'description ' => 'required|string ' ,
139
+ 'details ' => 'nullable|string ' ,
137
140
'userType ' => 'required|string ' ,
138
141
'userId ' => 'nullable|integer ' ,
139
142
'route ' => 'nullable| ' .$ route_url_check ,
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public function up()
23
23
Schema::connection ($ connection )->create ($ table , function (Blueprint $ table ) {
24
24
$ table ->increments ('id ' );
25
25
$ table ->longText ('description ' );
26
+ $ table ->longText ('details ' )->nullable ();
26
27
$ table ->string ('userType ' );
27
28
$ table ->integer ('userId ' )->nullable ();
28
29
$ table ->longText ('route ' )->nullable ();
Original file line number Diff line number Diff line change 86
86
'id ' => 'Aktivitätslog ID: ' ,
87
87
'ip ' => 'IP Adresse ' ,
88
88
'description ' => 'Beschreibung ' ,
89
+ 'details ' => 'Einzelheiten ' ,
89
90
'userType ' => 'Nutzertyp ' ,
90
91
'userId ' => 'Nutzer ID ' ,
91
92
'route ' => 'Route ' ,
107
108
'userCreatedAt ' => 'Erstellt ' ,
108
109
'userUpdatedAt ' => 'Bearbeitet ' ,
109
110
],
111
+
112
+ 'fields ' => [
113
+ 'none ' => 'Keiner ' ,
114
+ ],
110
115
],
111
116
112
117
],
Original file line number Diff line number Diff line change 86
86
'id ' => 'Activity Log ID: ' ,
87
87
'ip ' => 'Ip Address ' ,
88
88
'description ' => 'Description ' ,
89
+ 'details ' => 'Details ' ,
89
90
'userType ' => 'User Type ' ,
90
91
'userId ' => 'User Id ' ,
91
92
'route ' => 'Route ' ,
107
108
'userCreatedAt ' => 'Created ' ,
108
109
'userUpdatedAt ' => 'Updated ' ,
109
110
],
111
+
112
+ 'fields ' => [
113
+ 'none ' => 'None ' ,
114
+ ],
110
115
],
111
116
112
117
],
Original file line number Diff line number Diff line change 84
84
'id ' => 'Activité Id : ' ,
85
85
'ip ' => 'Adresse Ip ' ,
86
86
'description ' => 'Description ' ,
87
+ 'details ' => 'Détails ' ,
87
88
'userType ' => 'Type Utilisateur ' ,
88
89
'userId ' => 'Id Utilisateur ' ,
89
90
'route ' => 'Route ' ,
105
106
'userCreatedAt ' => 'Créé le ' ,
106
107
'userUpdatedAt ' => 'Actualisé le ' ,
107
108
],
109
+
110
+ 'fields ' => [
111
+ 'none ' => 'Aucun ' ,
112
+ ],
108
113
],
109
114
110
115
],
Original file line number Diff line number Diff line change 191
191
<dd >{{ $activity -> id } } </dd >
192
192
<dt >{!! trans (' LaravelLogger::laravel-logger.drilldown.list-group.labels.description' ) ! !} </dt >
193
193
<dd >{{ $activity -> description } } </dd >
194
+ <dt >{!! trans (' LaravelLogger::laravel-logger.drilldown.list-group.labels.details' ) ! !} </dt >
195
+ <dd >@if ($activity -> details ){{ $activity -> details } }@else {!! trans (' LaravelLogger::laravel-logger.drilldown.list-group.fields.none' ) ! !}@endif </dd >
194
196
<dt >{!! trans (' LaravelLogger::laravel-logger.drilldown.list-group.labels.route' ) ! !} </dt >
195
197
<dd >
196
198
<a href =" @if ($activity -> route != ' /' )/@endif {{ $activity -> route } }" >
You can’t perform that action at this time.
0 commit comments