File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ class Version extends Model
4040 'versionable ' ,
4141 ];
4242
43+ public function getIncrementing ()
44+ {
45+ return \config ('versionable.uuid ' ) ? false : parent ::getIncrementing ();
46+ }
47+
48+ public function getKeyType ()
49+ {
50+ return \config ('versionable.uuid ' ) ? 'string ' : parent ::getKeyType ();
51+ }
52+
4353 protected static function booted ()
4454 {
4555 static ::creating (function (Version $ version ) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests ;
4+
5+ class VersionWithUuidTest extends TestCase
6+ {
7+ protected function getEnvironmentSetUp ($ app )
8+ {
9+ parent ::getEnvironmentSetUp ($ app );
10+
11+ $ app ['config ' ]->set ('versionable.uuid ' , true );
12+ }
13+
14+ public function setUp (): void
15+ {
16+ parent ::setUp ();
17+
18+ Post::enableVersioning ();
19+
20+ config ([
21+ 'auth.providers.users.model ' => User::class,
22+ 'versionable.user_model ' => User::class,
23+ ]);
24+ }
25+
26+ public function testUuid ()
27+ {
28+ $ user = User::create (['name ' => 'overtrue ' ]);
29+ $ this ->actingAs ($ user );
30+
31+ $ post = Post::create (['title ' => 'Hello world! ' , 'content ' => 'Hello world! ' ]);
32+ $ version = $ post ->versions ()->first ();
33+
34+ $ this ->assertIsString ($ version ->id );
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments