-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from noxoua/develop
Develop
- Loading branch information
Showing
87 changed files
with
1,013 additions
and
592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.