<?php
namespace App\Casts;

use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class DelimiterCast  implements CastsAttributes
{
   public function get($model, string $key, $value, array $attributes)
   {
       $arr = explode(';', $value);
       foreach ($arr as &$item){
           $item = is_numeric($item) ? $item * 1: $item;
       }
       unset($item);
       return $arr;
   }

    public function set($model, string $key, $value, array $attributes)
    {
        return collect($value)->implode(';');
    }
}
