Skip to content
This repository was archived by the owner on Jan 4, 2024. It is now read-only.

Commit 460745a

Browse files
author
FoxWS
authored
Improve README.md
1 parent beb148b commit 460745a

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

README.md

+26-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
By default Livewire exposes database connection details. See the following [discussion](https://github.com/livewire/livewire/discussions/2627) for details.
1111

12-
This package encrypts the `dataMeta.models` response, so your database details cannot be retrieved.
12+
This package encrypts `memo.dataMeta.models` and `memo.dataMeta.modelCollections` responses, so your database details cannot easily be retrieved.
1313

14-
> **NOTE:** This package is a POC and comes without any warranty it actually works.
14+
> **NOTE:** This package is a POC and comes without any warranty it actually working.
1515
1616
## Installation
1717

@@ -23,18 +23,35 @@ composer require foxws/livewire-encrypt
2323

2424
This package should auto-register and overrule the Livewire `HydratePublicProperties` class.
2525

26-
### Filament
26+
## Filament
2727

28-
By default Livewire exposes all public properties to the view.
28+
> **NOTE:** By default Livewire exposes model properties to the view, unless it's defined in the model's `$hidden` property.
2929
30-
When using route binding, one may want to overrule the `id` attribute, to hide this from the public:
30+
When using [Filament](https://filamentphp.com/), one may want to force route-binding instead, and use the following trait on the Edit/View page:
3131

3232
```php
33-
protected function mutateFormDataBeforeFill(array $data): array
34-
{
35-
$data['id'] = $data['prefixed_id']; // slug, uuid, ..
33+
<?php
34+
35+
namespace App\Admin\Concerns;
3636

37-
return $data;
37+
trait InteractsWithFormData
38+
{
39+
protected function mutateFormDataBeforeFill(array $data): array
40+
{
41+
return $this->prepareFormDataBeforeFill($data);
42+
}
43+
44+
protected function prepareFormDataBeforeFill(array $data): array
45+
{
46+
// Replace model id with route-key
47+
$data['id'] = $this->getRecord()->getRouteKey();
48+
49+
if (array_key_exists('prefixed_id', $data)) {
50+
unset($data['prefixed_id']);
51+
}
52+
53+
return $data;
54+
}
3855
}
3956
```
4057

0 commit comments

Comments
 (0)