1. Go to this page and download the library: Download kolaybi/activity-log library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use KolayBi\ActivityLog\Contracts\ActivityGroup;
enum MyActivityGroup: string implements ActivityGroup
{
case NONE = 'none';
case COMPANY = 'company';
case USER = 'user';
}
use KolayBi\ActivityLog\AbstractActivity;
class CompanyCreatedActivity extends AbstractActivity
{
protected const MyActivityGroup GROUP = MyActivityGroup::COMPANY;
public function __construct(
private readonly Company $company,
) {}
protected function parameters(): array
{
return [
'company_name' => $this->company->name,
'company_type' => $this->company->company_type->value,
];
}
}
CompanyCreatedActivity::with($company)->log();
use KolayBi\ActivityLog\Contracts\ActivityContextProvider;
class MyContextProvider implements ActivityContextProvider
{
public function creatorId(): int|string|null
{
return Auth::id();
}
public function tenantId(): int|string|null
{
return tenant()?->id;
}
}