Skip to content

Commit 81d09fb

Browse files
author
Andreas Aagaard
committed
# Initial
1 parent 8f37a56 commit 81d09fb

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

migrations/create_activity_log_table.php.stub

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ class CreateActivityLogTable extends Migration
1313
{
1414
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
1515
$table->bigIncrements('id');
16-
$table->string('log_name')->nullable();
16+
$table->string('logName')->nullable();
1717
$table->text('description');
18-
$table->unsignedBigInteger('subject_id')->nullable();
19-
$table->string('subject_type')->nullable();
20-
$table->unsignedBigInteger('causer_id')->nullable();
21-
$table->string('causer_type')->nullable();
18+
$table->unsignedBigInteger('subjectID')->nullable();
19+
$table->string('subjectType')->nullable();
20+
$table->unsignedBigInteger('causerID')->nullable();
21+
$table->string('causerType')->nullable();
2222
$table->json('properties')->nullable();
23-
$table->timestamps();
23+
$table->dateTime('updated')->nullable();
24+
$table->dateTime('created')->nullable();
2425

25-
$table->index('log_name');
26-
$table->index(['subject_id', 'subject_type'], 'subject');
27-
$table->index(['causer_id', 'causer_type'], 'causer');
26+
$table->index('logName');
27+
$table->index(['subjectID', 'subjectType'], 'subject');
28+
$table->index(['causerID', 'causerType'], 'causer');
2829
});
2930
}
3031

src/ActivityLogger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public function by($modelOrId)
8080

8181
public function causedByAnonymous()
8282
{
83-
$this->activity->causer_id = null;
84-
$this->activity->causer_type = null;
83+
$this->activity->causerID = null;
84+
$this->activity->causerType = null;
8585

8686
return $this;
8787
}

src/Models/Activity.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ public function scopeInLog(Builder $query, ...$logNames): Builder
6969
$logNames = $logNames[0];
7070
}
7171

72-
return $query->whereIn('log_name', $logNames);
72+
return $query->whereIn('logName', $logNames);
7373
}
7474

7575
public function scopeCausedBy(Builder $query, Model $causer): Builder
7676
{
7777
return $query
78-
->where('causer_type', $causer->getMorphClass())
79-
->where('causer_id', $causer->getKey());
78+
->where('causerType', $causer->getMorphClass())
79+
->where('causerID', $causer->getKey());
8080
}
8181

8282
public function scopeForSubject(Builder $query, Model $subject): Builder
8383
{
8484
return $query
85-
->where('subject_type', $subject->getMorphClass())
86-
->where('subject_id', $subject->getKey());
85+
->where('subjectType', $subject->getMorphClass())
86+
->where('subjectID', $subject->getKey());
8787
}
8888
}

0 commit comments

Comments
 (0)