zeropad(dechex($value), 6); } /** * Prepare the given value for storage. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param array $value * @param array $attributes * @return int */ public function set($model, $key, $value, $attributes) { return \intval(hexdec(ltrim($value, '#'))); } private function zeropad($num, $lim) { return (strlen($num) >= $lim) ? $num : $this->zeropad("0" . $num, $lim); } }