You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 1, 2024. It is now read-only.
Finally, add the package's `Snowflakes` trait to the model:
108
+
Next, if you're using Eloquent, add the package's `Snowflakes` trait to your Eloquent models:
106
109
107
110
```php
108
111
<?php
@@ -111,15 +114,13 @@ namespace App\Models;
111
114
112
115
use Snowflake\Snowflakes;
113
116
114
-
class User extends Model
117
+
class Post extends Model
115
118
{
116
119
use Snowflakes;
117
120
}
118
121
```
119
122
120
-
#### Optional casting
121
-
122
-
The package also includes a custom `SnowflakeCast` that will automatically handle conversion from `string` to `integer` and vice-versa when storing or fetching a Snowflake from the database. If you wish, you may use this cast for any model attribute that will contain a Snowflake e.g.
123
+
Finally, configure the model's `$casts` array to use the package's `SnowflakeCast` for all Snowflake attributes. This cast automatically handles conversion from `string` to `integer` and vice-versa when storing or fetching a Snowflake from the database. It also ensures that languages which do not support 64-bit integers (such as JavaScript), will not truncate the Snowflake.
0 commit comments