<?php
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class HttpToHttpsArray  implements CastsAttributes
{
    public function get($model, string $key, $value, array $attributes)
    {
        $arr = json_decode($value,true);
        foreach ($arr as &$item){
            $item = str_replace('http://','https://',$item);
            $item = str_replace('-internal','',$item);
        }
        return $arr;
    }


    public function set($model, string $key, $value, array $attributes)
    {
        foreach ($value as &$item){
            $item = str_replace('http://','https://',$item);
            $item = str_replace('-internal','',$item);
        }
        return json_encode($value);
    }
}
