File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ public static function bootCachable()
27
27
static ::deleted (function ($ instance ) {
28
28
$ instance ->checkCooldownAndFlushAfterPersiting ($ instance );
29
29
});
30
+
30
31
static ::saved (function ($ instance ) {
31
32
$ instance ->checkCooldownAndFlushAfterPersiting ($ instance );
32
33
});
Original file line number Diff line number Diff line change
1
+ <?php namespace GeneaLabs \LaravelModelCaching \Tests \Integration ;
2
+
3
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \Author ;
4
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \Book ;
5
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \Profile ;
6
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \Publisher ;
7
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \Store ;
8
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \UncachedAuthor ;
9
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \UncachedBook ;
10
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \UncachedProfile ;
11
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \UncachedPublisher ;
12
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \UncachedStore ;
13
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \Http \Resources \Author as AuthorResource ;
14
+ use GeneaLabs \LaravelModelCaching \Tests \IntegrationTestCase ;
15
+ use Illuminate \Foundation \Testing \RefreshDatabase ;
16
+ use Illuminate \Support \Collection ;
17
+
18
+ class UpdateExistingPivotTest extends IntegrationTestCase
19
+ {
20
+ use RefreshDatabase;
21
+
22
+ public function testInRandomOrderCachesResults ()
23
+ {
24
+ $ book = (new Book )
25
+ ->with ("stores " )
26
+ ->whereHas ("stores " )
27
+ ->first ();
28
+ $ book ->stores ()
29
+ ->updateExistingPivot (
30
+ $ book ->stores ->first ()->id ,
31
+ ["test " => "value " ]
32
+ );
33
+ $ updatedCount = (new Book )
34
+ ->with ("stores " )
35
+ ->whereHas ("stores " )
36
+ ->first ()
37
+ ->stores ()
38
+ ->wherePivot ("test " , "value " )
39
+ ->count ();
40
+
41
+ $ this ->assertEquals (1 , $ updatedCount );
42
+ }
43
+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ public function up()
13
13
$ table ->unsignedInteger ('store_id ' );
14
14
$ table ->timestamps ();
15
15
16
+ $ table ->string ("test " )->nullable ();
17
+
16
18
$ table ->foreign ('book_id ' )
17
19
->references ('id ' )
18
20
->on ('books ' )
You can’t perform that action at this time.
0 commit comments