name, $this->shouldCast)) { return $value; } return explode(',', $value); } /** * Prepare the given value for storage. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param mixed $value * @param array $attributes * @return mixed */ public function set($model, $key, $value, $attributes) { if (!in_array($model->name, $this->shouldCast)) { return $value; } return implode(',', $value); } }