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
3939| Routing Events can recording using middleware|
4040| Records activity timestamps|
4141| Records activity description|
42+ | Records activity details (optional)|
4243| Records activity user type with crawler detection.|
4344| Records activity Method|
4445| Records activity Route|
@@ -218,20 +219,25 @@ When using the trait you can customize the event description.
218219To use the trait:
2192201 . Include the call in the head of your class file:
220221
221- ``` php
222- use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
223- ```
222+ ``` php
223+ use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
224+ ```
224225
2252262. Include the trait call in the opening of your class:
226227
227- ``` php
228- use ActivityLogger;
229- ```
228+ ```php
229+ use ActivityLogger;
230+ ```
230231
2312323. 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+ ```
235241
236242### Routes
237243##### Laravel Activity Dashbaord Routes
Original file line number Diff line number Diff line change @@ -13,11 +13,12 @@ trait ActivityLogger
1313 /**
1414 * Laravel Logger Log Activity.
1515 *
16- * @param string $description
16+ * @param null $description
17+ * @param null $details
1718 *
1819 * @return void
1920 */
20- public static function activity ($ description = null )
21+ public static function activity ($ description = null , $ details = null )
2122 {
2223 $ userType = trans ('LaravelLogger::laravel-logger.userTypes.guest ' );
2324 $ userId = null ;
@@ -61,6 +62,7 @@ public static function activity($description = null)
6162
6263 $ data = [
6364 'description ' => $ description ,
65+ 'details ' => $ details ,
6466 'userType ' => $ userType ,
6567 'userId ' => $ userId ,
6668 'route ' => Request::fullUrl (),
@@ -94,6 +96,7 @@ private static function storeActivity($data)
9496 {
9597 config ('laravel-logger.defaultActivityModel ' )::create ([
9698 'description ' => $ data ['description ' ],
99+ 'details ' => $ data ['details ' ],
97100 'userType ' => $ data ['userType ' ],
98101 'userId ' => $ data ['userId ' ],
99102 'route ' => $ data ['route ' ],
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ class Activity extends Model
5757 */
5858 protected $ fillable = [
5959 'description ' ,
60+ 'details ' ,
6061 'userType ' ,
6162 'userId ' ,
6263 'route ' ,
@@ -69,6 +70,7 @@ class Activity extends Model
6970
7071 protected $ casts = [
7172 'description ' => 'string ' ,
73+ 'details ' => 'string ' ,
7274 'user ' => 'integer ' ,
7375 'route ' => 'string ' ,
7476 'ipAddress ' => 'string ' ,
@@ -134,6 +136,7 @@ public static function rules($merge = [])
134136 return array_merge (
135137 [
136138 'description ' => 'required|string ' ,
139+ 'details ' => 'nullable|string ' ,
137140 'userType ' => 'required|string ' ,
138141 'userId ' => 'nullable|integer ' ,
139142 'route ' => 'nullable| ' .$ route_url_check ,
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public function up()
2323 Schema::connection ($ connection )->create ($ table , function (Blueprint $ table ) {
2424 $ table ->increments ('id ' );
2525 $ table ->longText ('description ' );
26+ $ table ->longText ('details ' )->nullable ();
2627 $ table ->string ('userType ' );
2728 $ table ->integer ('userId ' )->nullable ();
2829 $ table ->longText ('route ' )->nullable ();
Original file line number Diff line number Diff line change 8686 'id ' => 'Aktivitätslog ID: ' ,
8787 'ip ' => 'IP Adresse ' ,
8888 'description ' => 'Beschreibung ' ,
89+ 'details ' => 'Einzelheiten ' ,
8990 'userType ' => 'Nutzertyp ' ,
9091 'userId ' => 'Nutzer ID ' ,
9192 'route ' => 'Route ' ,
107108 'userCreatedAt ' => 'Erstellt ' ,
108109 'userUpdatedAt ' => 'Bearbeitet ' ,
109110 ],
111+
112+ 'fields ' => [
113+ 'none ' => 'Keiner ' ,
114+ ],
110115 ],
111116
112117 ],
Original file line number Diff line number Diff line change 8686 'id ' => 'Activity Log ID: ' ,
8787 'ip ' => 'Ip Address ' ,
8888 'description ' => 'Description ' ,
89+ 'details ' => 'Details ' ,
8990 'userType ' => 'User Type ' ,
9091 'userId ' => 'User Id ' ,
9192 'route ' => 'Route ' ,
107108 'userCreatedAt ' => 'Created ' ,
108109 'userUpdatedAt ' => 'Updated ' ,
109110 ],
111+
112+ 'fields ' => [
113+ 'none ' => 'None ' ,
114+ ],
110115 ],
111116
112117 ],
Original file line number Diff line number Diff line change 8484 'id ' => 'Activité Id : ' ,
8585 'ip ' => 'Adresse Ip ' ,
8686 'description ' => 'Description ' ,
87+ 'details ' => 'Détails ' ,
8788 'userType ' => 'Type Utilisateur ' ,
8889 'userId ' => 'Id Utilisateur ' ,
8990 'route ' => 'Route ' ,
105106 'userCreatedAt ' => 'Créé le ' ,
106107 'userUpdatedAt ' => 'Actualisé le ' ,
107108 ],
109+
110+ 'fields ' => [
111+ 'none ' => 'Aucun ' ,
112+ ],
108113 ],
109114
110115 ],
Original file line number Diff line number Diff line change 191191 <dd >{{ $activity -> id } } </dd >
192192 <dt >{!! trans (' LaravelLogger::laravel-logger.drilldown.list-group.labels.description' ) ! !} </dt >
193193 <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 >
194196 <dt >{!! trans (' LaravelLogger::laravel-logger.drilldown.list-group.labels.route' ) ! !} </dt >
195197 <dd >
196198 <a href =" @if ($activity -> route != ' /' )/@endif {{ $activity -> route } }" >
You can’t perform that action at this time.
0 commit comments