laravel从旅行者的文本中获取数组

trying to save Text as array in database so i write

  some Text
  some Text,
  some Text;
  some Text.

and it being saved in databse as

        ["some Text
some Text,
some Text;
some Text."]

how can i save it in this format

        ["some Text" ,"some Text,","some Text;" , "some Text."]

is there any break or something

protected $casts = [
'array_value' => 'array',
];


public function setArrayValueAttribute($value)
{
    $this->attributes['array_value'] = json_encode($value);
}

public function getArrayValueAttribute($value)
{
    return collect(json_decode($value));
}

You could just brute force it in the setter.

public function setArrayValueAttribute($value)
{
    $newArray = [];
    foreach($value as $item) {
        $items = explode("
", $item);
        array_push($newArray, $items);
    }

    $this->attributes['array_value'] = json_encode($newArray);
}

But that will only work for your example use case above. If you're expecting any other types of new line characters, you'll have to deal with them also.