Last active
October 19, 2020 15:50
-
-
Save hanafiah/c0c9a05a5dcea08ac1117b986ed83a99 to your computer and use it in GitHub Desktop.
contoh cast hashid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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