Skip to content

Commit 17add5b

Browse files
committed
Add Telescope work-around
1 parent f196b06 commit 17add5b

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,38 @@ composer require genealabs/laravel-model-caching:*
4848
```
4949

5050
## Configuration
51+
### Telescope Compatibility
52+
Due to how a dependent package fires pivot events that are currently
53+
incompatible with Laravel Telescope, you will need to adjust your Model Watcher
54+
in your Telescope configuration, if you use Telescope (if not, you can safely
55+
ignore this section):
56+
57+
```php
58+
use GeneaLabs\LaravelModelCaching\Telescope\ModelWatcher as CustomModelWatcher;
59+
// ...
60+
61+
return [
62+
63+
// ...
64+
65+
'watchers' => [
66+
67+
// ...
68+
69+
CustomModelWatcher::class => [
70+
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
71+
'events' => ['eloquent.*'],
72+
],
73+
74+
// ...
75+
76+
],
77+
78+
// ...
79+
80+
];
81+
```
82+
5183
### Recommended (Optional) Custom Cache Store
5284
If you would like to use a different cache store than the default one used by
5385
your Laravel application, you may do so by setting the `MODEL_CACHE_STORE`

src/Telescope/ModelWatcher.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php namespace GeneaLabs\LaravelModelCaching\Telescope;
2+
3+
use \Laravel\Telescope\Watchers\ModelWatcher as PackageWatcher;
4+
5+
class ModelWatcher extends PackageWatcher
6+
{
7+
public function recordAction($event, $data)
8+
{
9+
$modifiedData = $data;
10+
$modifiedData[0] = $modifiedData[0] ?? $modifiedData['model'];
11+
12+
parent::recordAction($event, $modifiedData);
13+
}
14+
}

0 commit comments

Comments
 (0)