<?php

namespace Modules\Core\Traits;

use Illuminate\Support\Facades\Auth;

trait HasActionContext
{
    public function attach(?string $actionByField = null, ?string $dateField = null): array
    {
        $data = [];

        if ($actionByField !== null) {
            $data[$actionByField] = Auth::id();
        }
        
        if ($dateField !== null) {
            $data[$dateField] = now();
        }

        return $data;
    }
}
