<?php

namespace App\Models;
use App\Http\Traits\Timezone;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;


class ShortUrl extends Model
{
    use HasFactory, Timezone;

    Protected $dates = ['created_at', 'updated_at'];
    Protected $fillable = ['short_key', 'parameters', 'expire_time'];
    protected $casts = [
        'created_at' => 'datetime:d-m-Y H:i:s'
    ];

    public function Parameteres(): Attribute
    {
        return Attribute::make(
            function ($value) {
                return json_decode($value,true);
                
            },function ($value){
               return json_encode($value);
            }
        );
    }

    
}
