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

Commit

Permalink
add cast
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkingshott committed Jan 17, 2022
1 parent 5de3107 commit a5b5398
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/SnowflakeCast.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);

namespace Snowflake;

use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class SnowflakeCast implements CastsAttributes
{
/**
* Cast the given value.
*
*/
public function get($model, string $key, $value, array $attributes) : string
{
return (string) $value;
}

/**
* Prepare the given value for storage.
*
*/
public function set($model, string $key, $value, array $attributes) : mixed
{
return (int) $value;
}
}

0 comments on commit a5b5398

Please sign in to comment.