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|
@@ -218,20 +219,25 @@ When using the trait you can customize the event description.
218
219
To use the trait:
219
220
1 . Include the call in the head of your class file:
220
221
221
- ``` php
222
- use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
223
- ```
222
+ ``` php
223
+ use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
224
+ ```
224
225
225
226
2. Include the trait call in the opening of your class:
226
227
227
- ``` php
228
- use ActivityLogger;
229
- ```
228
+ ```php
229
+ use ActivityLogger;
230
+ ```
230
231
231
232
3. You can record the activity my calling the traits method:
232
- ```
233
- ActivityLogger::activity("Logging this activity.");
234
- ```
233
+ ```
234
+ ActivityLogger::activity("Logging this activity.");
235
+ ```
236
+
237
+ Or as bellow to include extended activity details:
238
+ ```
239
+ ActivityLogger::activity("Logging this activity.", "Additional activity details.");
240
+ ```
235
241
236
242
### Routes
237
243
##### Laravel Activity Dashbaord Routes
Original file line number Diff line number Diff line change @@ -13,11 +13,12 @@ trait ActivityLogger
13
13
/**
14
14
* Laravel Logger Log Activity.
15
15
*
16
- * @param string $description
16
+ * @param null $description
17
+ * @param null $details
17
18
*
18
19
* @return void
19
20
*/
20
- public static function activity ($ description = null )
21
+ public static function activity ($ description = null , $ details = null )
21
22
{
22
23
$ userType = trans ('LaravelLogger::laravel-logger.userTypes.guest ' );
23
24
$ userId = null ;
@@ -61,6 +62,7 @@ public static function activity($description = null)
61
62
62
63
$ data = [
63
64
'description ' => $ description ,
65
+ 'details ' => $ details ,
64
66
'userType ' => $ userType ,
65
67
'userId ' => $ userId ,
66
68
'route ' => Request::fullUrl (),
@@ -94,6 +96,7 @@ private static function storeActivity($data)
94
96
{
95
97
config ('laravel-logger.defaultActivityModel ' )::create ([
96
98
'description ' => $ data ['description ' ],
99
+ 'details ' => $ data ['details ' ],
97
100
'userType ' => $ data ['userType ' ],
98
101
'userId ' => $ data ['userId ' ],
99
102
'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