Skip to content

Commit 12eab70

Browse files
author
phoenix
committed
fix -- for package laravel-eloquent-query-cache, BelongsTo handler flush cache after save for models where package in used
1 parent 4a7a1ff commit 12eab70

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Domain/Relation/Handlers/BelongsToHandler.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function attach( $model, $relationship, $value): void
3535
$model->save();
3636

3737
$model->setEventDispatcher($dispatcher);
38+
39+
if (method_exists($model, 'flushQueryCache'))
40+
{
41+
$reflection = new \ReflectionMethod($model, 'flushQueryCache');
42+
if ($reflection->isPublic())
43+
{
44+
$model->flushQueryCache();
45+
}
46+
}
3847
}
3948

4049
public function retrieve($model, $relationship, $idKey)

0 commit comments

Comments
 (0)