File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public static function bootGeneratesUuid()
61
61
$ uuid = $ uuid ->fromString (strtolower ($ model ->attributes [$ model ->uuidColumn ()]));
62
62
}
63
63
64
- $ model ->attributes [$ model ->uuidColumn ()] = $ model ->hasCast ('uuid ' ) ? $ uuid ->getBytes () : $ uuid ->toString ();
64
+ $ model ->attributes [$ model ->uuidColumn ()] = $ model ->hasCast ($ model -> uuidColumn (), 'uuid ' ) ? $ uuid ->getBytes () : $ uuid ->toString ();
65
65
});
66
66
}
67
67
Original file line number Diff line number Diff line change 9
9
use Illuminate \Events \Dispatcher ;
10
10
use Tests \Fixtures \CustomUuidPost ;
11
11
use Illuminate \Container \Container ;
12
+ use Tests \Fixtures \CustomCastUuidPost ;
12
13
use Illuminate \Database \Capsule \Manager ;
13
14
14
15
class UuidTest extends TestCase
@@ -68,6 +69,14 @@ public function you_can_generate_a_uuid_without_casting()
68
69
$ this ->assertNotNull ($ post ->uuid );
69
70
}
70
71
72
+ /** @test */
73
+ public function you_can_generate_a_uuid_with_casting_and_a_custom_field_name ()
74
+ {
75
+ $ post = CustomCastUuidPost::create (['title ' => 'test post ' ]);
76
+
77
+ $ this ->assertNotNull ($ post ->custom_uuid );
78
+ }
79
+
71
80
/** @test */
72
81
public function you_can_specify_a_uuid_without_casting ()
73
82
{
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests \Fixtures ;
4
+
5
+ class CustomCastUuidPost extends Model
6
+ {
7
+
8
+ /**
9
+ * {@inheritdoc}
10
+ */
11
+ protected $ casts = ['custom_uuid ' => 'uuid ' ];
12
+
13
+ public function uuidColumn ()
14
+ {
15
+ return 'custom_uuid ' ;
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments