PHP code example of djl997 / filament-model-activity-page
1. Go to this page and download the library: Download djl997/filament-model-activity-page 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/ */
djl997 / filament-model-activity-page example snippets
use Djl997\FilamentModelActivityPage\Traits\HasActivities;
class Company extends Model
{
use HasActivities;
}
use Djl997\FilamentModelActivityPage\Pages\ActivityPage;
class Notes extends ActivityPage
{
protected static string $resource = CompanyResource::class;
protected function isPrivilegedUser(): bool
{
return auth()->user()->isAdmin();
}
protected function canSendInternalMessages(): bool
{
return auth()->user()->isAdmin();
}
protected function afterClientMessage(array $data): void
{
// Send notification, fire event, etc.
}
}
public static function getPages(): array
{
return [
// ...
'notes' => Notes::route('/{record}/notes'),
];
}
protected function resolveActivityIcon(array $activity): ?string
{
// Show an envelope icon on event activities that contain "email" in the message
if ($activity['level'] === 'event' && str_contains($activity['message'], 'email')) {
return 'heroicon-m-envelope';
}
return null;
}