Skip to content
This repository was archived by the owner on Apr 1, 2024. It is now read-only.

Commit a5b5398

Browse files
committed
add cast
1 parent 5de3107 commit a5b5398

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/SnowflakeCast.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Snowflake;
4+
5+
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
6+
7+
class SnowflakeCast implements CastsAttributes
8+
{
9+
/**
10+
* Cast the given value.
11+
*
12+
*/
13+
public function get($model, string $key, $value, array $attributes) : string
14+
{
15+
return (string) $value;
16+
}
17+
18+
/**
19+
* Prepare the given value for storage.
20+
*
21+
*/
22+
public function set($model, string $key, $value, array $attributes) : mixed
23+
{
24+
return (int) $value;
25+
}
26+
}

0 commit comments

Comments
 (0)