Skip to content

Commit

Permalink
Merge pull request #19 from bilaliqbalr/patch-1
Browse files Browse the repository at this point in the history
Moved activity query out of private function
  • Loading branch information
199ocero authored Feb 3, 2024
2 parents c88d2fa + 202281f commit ac3869b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Concerns/HasSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,21 @@ public function activityInfolist(Infolist $infolist): Infolist
->columns(1);
}

private function getActivityLogRecord(): Collection
{
protected function getActivites() : \Illuminate\Database\Eloquent\Collection {
$activityModelClass = config('activitylog.activity_model');
$activityModel = new $activityModelClass;

$activities = $activityModel::query()
return $activityModel::query()
->with(['causer', 'subject'])
->where('subject_id', $this->record->id)
->where('subject_type', get_class($this->record))
->orderBy('created_at', 'desc')
->get();
}

private function getActivityLogRecord(): Collection
{
$activities = $this->getActivites();

$activities->transform(function ($activity) {

Expand Down

0 comments on commit ac3869b

Please sign in to comment.