Skip to content

Instantly share code, notes, and snippets.

@hanafiah
Last active October 19, 2020 15:50
Show Gist options
  • Save hanafiah/c0c9a05a5dcea08ac1117b986ed83a99 to your computer and use it in GitHub Desktop.
Save hanafiah/c0c9a05a5dcea08ac1117b986ed83a99 to your computer and use it in GitHub Desktop.
contoh cast hashid
class HashIdCast implements CastsAttributes
{
public function get($model, $key, $value, $attributes)
{
$hash = new Hashids();
return $hash->encode($value);
}
public function set($model, $key, $value, $attributes)
{
$hash = new Hashids();
return $hash->decode($value)[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment