diff --git a/database/migrations/2016_05_22_190217_add_fields_to_log_table.php b/database/migrations/2016_05_22_190217_add_fields_to_log_table.php new file mode 100644 index 00000000..a66ee01c --- /dev/null +++ b/database/migrations/2016_05_22_190217_add_fields_to_log_table.php @@ -0,0 +1,33 @@ +string('route')->after('type')->nullable(); + $table->ipAddress('ip')->after('route')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('logs', function (Blueprint $table) { + $table->dropColumn('route'); + $table->dropColumn('ip'); + }); + } +} diff --git a/src/AuditingTrait.php b/src/AuditingTrait.php index 86b1967a..0b9bebbd 100644 --- a/src/AuditingTrait.php +++ b/src/AuditingTrait.php @@ -244,6 +244,8 @@ public function audit(array $log, $type) 'owner_id' => $this->getKey(), 'user_id' => $this->getUserId(), 'type' => $type, + 'route' => \Request::route()->getName() ? \Request::route()->getName() : \Request::route()->getUri(), + 'ip' => \Request::ip(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime(), ];