v7.0.0-beta.1 release
This commit is contained in:
commit
6595fd0eb5
3967 files changed
+1875383
No files matched your search
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use App\Services\ActivityLogService;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
/**
|
||||
* 활동 로그 조회 기능을 제공하는 Trait
|
||||
*
|
||||
* 모델에서 use LogsActivity; 하여 활동 로그 관계 및 조회 기능을 사용할 수 있습니다.
|
||||
* 기록은 Log::channel('activity') → ActivityLogHandler를 통해 직접 수행합니다.
|
||||
*/
|
||||
trait LogsActivity
|
||||
{
|
||||
/**
|
||||
* 이 모델과 관련된 활동 로그 관계
|
||||
*
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function activityLogs(): MorphMany
|
||||
{
|
||||
return $this->morphMany(ActivityLog::class, 'loggable')
|
||||
->latest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 이 모델의 활동 로그 목록을 조회합니다.
|
||||
*
|
||||
* @param array $filters 필터 조건
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator 페이지네이션된 로그 목록
|
||||
*/
|
||||
public function getActivityLogs(array $filters = []): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
{
|
||||
return app(ActivityLogService::class)->getLogsForModel($this, $filters);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user