mercredi 1 mai 2019

laravel get array from text in voyager

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\r\nsome Text,\r\nsome Text;\r\nsome 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));
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire