@bwrigley Hi. If you use the hashed casting attribute, you don’t need to hash the value before.
As you can see in the Illuminate\Database\Eloquent\Concerns\HasAttributes trait, there is a test to check if the value is already hashed to prevent double-hashing:
/**
* Cast the given attribute to a hashed string.
*
* @param string $key
* @param mixed $value
* @return string
*/
protected function castAttributeAsHashedString($key, $value)
{
if ($value === null) {
return null;
}
if (! Hash::isHashed($value)) {
return Hash::make($value);
}
if (! Hash::verifyConfiguration($value)) {
throw new RuntimeException("Could not verify the hashed value's configuration.");
}
return $value;
}