Appearance
PivotActivityFluent
php
class Zairakai\LaravelActivity\Support\PivotActivityFluentFluent API for pivot table activity logging.
Source: src/Support/PivotActivityFluent.php
Methods
__construct()
php
public function __construct(BelongsToMany $relation)attach()
php
public function attach(mixed $ids, array $attributes = [], bool $touch = true): voidAttach models to the pivot table with activity logging.
by()
php
public function by(Model $model = null): staticSet the user or model causing this activity.
byAnonymous()
php
public function byAnonymous(): staticMark activity as anonymous (no causer).
detach()
php
public function detach(mixed $ids = null, bool $touch = true): intDetach models from the pivot table with activity logging.
| Parameter | Description |
|---|---|
$ids | IDs to detach, or null to detach all |
$touch | Whether to touch parent timestamps |
Returns int Number of detached records
sync()
php
public function sync(array|Collection|Model $ids, bool $detaching = true): arraySync the pivot table with activity logging.
Returns array<string, array<int, int|string>>
syncWithoutDetaching()
php
public function syncWithoutDetaching(array|Collection|Model $ids): arraySync without detaching with activity logging.
Returns array<string, array<int, int|string>>
toggle()
php
public function toggle(mixed $ids, bool $touch = true): arrayToggle models in the pivot table with activity logging.
| Parameter | Description |
|---|---|
$ids | IDs to toggle |
$touch | Whether to touch parent timestamps |
Returns array<string, array<int, int|string>> Result with 'attached' and 'detached' keys
updateExistingPivot()
php
public function updateExistingPivot(array|int|string $ids, array $attributes, bool $touch = true): intUpdate existing pivot attributes with activity logging.
withMessage()
php
public function withMessage(string $message): staticSet a custom log message.
getCurrentPivotIds()
php
protected function getCurrentPivotIds(): arrayReturns array<int, int|string>
getPivotAttributes()
php
protected function getPivotAttributes(array $ids): arrayReturns array<int|string, array<string, mixed>>
hasChanged()
php
protected function hasChanged(array $before, array $after): boollogActivity()
php
protected function logActivity(string $operation, mixed $before, mixed $after, string $defaultMessage): voidWrite an activity log entry for the current operation.
| Parameter | Description |
|---|---|
$operation | Operation name (attached, detached, synced, …) |
$before | State before the operation |
$after | State after the operation |
$defaultMessage | Fallback message when no custom message is set |
normalizeIds()
php
protected function normalizeIds(mixed $ids): arrayReturns array<int, int|string>