44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Repositories;
|
|
|
|
use App\Models\ClientActivityTimeline;
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
|
|
|
class ClientActivityTimelineRepository extends BaseRepository implements ClientActivityTimelineRepositoryInterface
|
|
{
|
|
public function __construct(ClientActivityTimeline $model)
|
|
{
|
|
parent::__construct($model);
|
|
}
|
|
|
|
/**
|
|
* Get paginated timeline for a specific client
|
|
*
|
|
* @param int $clientId
|
|
* @param int $perPage
|
|
* @return LengthAwarePaginator
|
|
*/
|
|
public function getByClient(int $clientId, int $perPage = 15): LengthAwarePaginator
|
|
{
|
|
return $this->model
|
|
->where('client_id', $clientId)
|
|
->with('actor') // Load actor relationship
|
|
->orderBy('created_at', 'desc')
|
|
->paginate($perPage);
|
|
}
|
|
|
|
/**
|
|
* Log a new activity
|
|
*
|
|
* @param array $data
|
|
* @return ClientActivityTimeline
|
|
*/
|
|
public function logActivity(array $data)
|
|
{
|
|
return $this->create($data);
|
|
}
|
|
}
|