Skip to content

Commit

Permalink
Merge pull request #34 from noxoua/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
noxoua authored Nov 4, 2023
2 parents 98482d4 + fa5b490 commit bb50fd1
Show file tree
Hide file tree
Showing 87 changed files with 1,013 additions and 592 deletions.
2 changes: 1 addition & 1 deletion config/filament-activity-log.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Noxo\FilamentActivityLog\Fields\Types\BooleanEnum;
use Noxo\FilamentActivityLog\ResourceLogger\Types\BooleanEnum;

return [
'loggers' => [
Expand Down
20 changes: 1 addition & 19 deletions docs/002-installation.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Installation
permalink: /installation
nav_order: 2
---

# Installation

## Install via Composer
____

{: .highlight }
Expand All @@ -32,21 +32,3 @@ Optionally, you can publish the `translations` file with:
```bash
php artisan vendor:publish --tag="filament-activity-log-translations"
```

## Adding Activity Page
____

Create a page in your pages folder `app/Filament/Pages/` and extends the `ListActivities` class.

```php
<?php

namespace App\Filament\Pages;

use Noxo\FilamentActivityLog\Pages\ListActivities;

class Activities extends ListActivities
{
//
}
```
62 changes: 5 additions & 57 deletions docs/003-get-started.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,14 @@
---
title: Get Started
permalink: /get-started
nav_order: 3
has_children: true
---

# Get Started

### Logger Class
___

The Logger class is a fundamental component of the "Filament Activity Log" package, responsible for capturing and logging activities related to specific models within your Laravel application. It offers powerful customization options to define precisely which events and data changes should be recorded, making it a flexible and versatile tool for tracking model-related actions.

### Create a Logger

Use the artisan command to create a logger.

```bash
php artisan make:filament-logger User
```

{: .note }
Once `UserLogger` is created, it immediately starts listening to model events.


### Sample
## Logger Class

Here's a simple example of how to create a Logger for a User model:

```php
use App\Filament\Resources\UserResource;
use App\Models\User;
use Illuminate\Contracts\Support\Htmlable;
use Noxo\FilamentActivityLog\Fields\Fields;
use Noxo\FilamentActivityLog\Fields\Field;
use Noxo\FilamentActivityLog\Loggers\Logger;

class UserLogger extends Logger
{
// public static bool $disabled = true;

public static ?string $model = User::class;

public static ?array $events = [
// 'created',
// 'updated',
'deleted',
'restored',
];

public static function getLabel(): string|Htmlable|null
{
// return __('User');
return UserResource::getModelLabel();
}

public static function fields(Fields $fields): Fields
{
return $fields->schema([
'name',
'email',
'email_verified_at' => fn (Field $field) => $field->date()->badge(),
'roles' => fn (Field $field) => $field->relation('name'),
'media' => fn (Field $field) => $field->media(),
]);
}
}
```
The Logger class is a fundamental component of the "Filament Activity Log" package, responsible for capturing and logging activities related to specific models within your Laravel application. It offers powerful customization options to define precisely which events and data changes should be recorded, making it a flexible and versatile tool for tracking model-related actions.
22 changes: 13 additions & 9 deletions docs/004-fields.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
---
title: Fields
permalink: /fields
nav_order: 4
has_children: true
---

# Fields

___

In the context of the Logger class, you have the flexibility to define which fields and relations should be logged for your model. This allows you to track changes to specific attributes and related data.


### Badge

```php
$fields->schema([
$logger->fields([
'name' => 'badge:danger',
// 'name' => fn (Field $field) => $field->badge('danger'),
])
Expand All @@ -24,7 +28,7 @@ ____
### Enum

```php
$fields->schema([
$logger->fields([
'status' => fn (Field $field) => $field
->enum(App\Enums\OrderStatus::class)
->label('Status'),
Expand All @@ -38,7 +42,7 @@ ____
### Date & Time

```php
$fields->schema([
$logger->fields([
// 'published_at' => 'date:j F, Y'',
// 'published_at' => 'time',
// 'published_at' => 'datetime',
Expand All @@ -55,7 +59,7 @@ ____
### Boolean

```php
$fields->schema([
$logger->fields([
// 'is_visible' => 'boolean',
'is_visible' => fn (Field $field) => $field
->boolean()
Expand All @@ -70,7 +74,7 @@ ____
### Media

```php
$fields->schema([
$logger->fields([
// 'media' => 'media',
'media' => fn (Field $field) => $field
->media(gallery: true)
Expand All @@ -85,7 +89,7 @@ ____
### Money

```php
$fields->schema([
$logger->fields([
// 'price' => 'money:EUR',
'price' => fn (Field $field) => $field->money('EUR'),
])
Expand All @@ -98,7 +102,7 @@ ____
### Key-Value

```php
$fields->schema([
$logger->fields([
'meta' => fn (Field $field) => $field
->view('key-value')
->label('Attributes'),
Expand All @@ -112,7 +116,7 @@ ____
### Relation

```php
$fields->schema([
$logger->fields([
// 'categories' => 'relation:name',
'categories' => fn (Field $field) => $field
->relation('name') // get names only
Expand All @@ -128,7 +132,7 @@ ____
### Table

```php
$fields->schema([
$logger->fields([
'items' => fn (Field $field) => $field
->relation()
->table()
Expand Down
28 changes: 28 additions & 0 deletions docs/005-relation-manager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Relation Manager
permalink: /relation-manager
nav_order: 5
---

# Relation Manager

___

In Filament, you can create special "relation managers" for handling related data in your resource. Imagine you have a resource with a relation called `accessories`. Here's a straightforward example of defining such a relation manager:

```php
$logger->relationManagers([
'accessories' => fn (RelationManager $relationManager) => $relationManager
->label('Accessory')
->fields([
'name' => fn (Field $field) => $field
->label(__('Label')),

'price' => fn (Field $field) => $field
->label(__('Price'))
->money('EUR'),
]),
]);
```

By creating relation managers, you can organize and format related data the way you want in your Filament application.
157 changes: 0 additions & 157 deletions docs/005-usage-with-relations.md

This file was deleted.

Loading

0 comments on commit bb50fd1

Please sign in to comment.