<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Split extends Model
{
    protected $fillable = [
        'name', 'country', 'link_reg', 'link_play'
    ];

    public function setCountryAttribute($value)
    {
        $country = [];

        if(! empty($value)) {
            $country = explode(',', $value);
            $country = array_map(function($value) {
                return trim($value);
            }, $country);
        }

        $this->attributes['country'] = serialize($country);
    }

    public function getCountryAttribute($value)
    {
        return unserialize($value);
    }
}
