We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 91fac03 + e5d93cd commit 9f2ff1eCopy full SHA for 9f2ff1e
src/Traits/BuilderCaching.php
@@ -12,4 +12,13 @@ public function all($columns = ['*']) : Collection
12
13
return $this->model->get($columns);
14
}
15
+
16
+ public function truncate()
17
+ {
18
+ if ($this->isCachable()) {
19
+ $this->model->flushCache();
20
+ }
21
22
+ return parent::truncate();
23
24
tests/Integration/Traits/BuilderCachingTest.php
@@ -24,4 +24,12 @@ public function testDisablingAllQuery()
$this->assertInstanceOf(Collection::class, $allAuthors);
25
$this->assertNull($cachedAuthors);
26
27
28
+ public function testUsingTruncateInvalidatesCache()
29
30
+ (new Author)->get();
31
+ Author::truncate();
32
33
+ $this->assertTrue((new Author)->get()->isEmpty());
34
35
0 commit comments