<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

class PermitsReminder extends Model
{
    use SoftDeletes;

    protected $table = 'permits_reminders';

    protected $dates = ['deleted_at'];

    protected $fillable = ['model', 'expiry_date', 'reminder_date'];

    public function getExpiryDateAttribute($value)
    {
        return $this->attributes['expiry_date'] === null ? NULL : Carbon::parse($this->attributes['expiry_date'])->format('d-m-Y');
    }

    public function getReminderDateAttribute($value)
    {
        return $this->attributes['reminder_date'] === null ? NULL : Carbon::parse($this->attributes['reminder_date'])->format('d-m-Y');
    }

    public function getCreatedAtAttribute($value)
    {
        return $this->attributes['created_at'] === null ? NULL : Carbon::parse($this->attributes['created_at'])->format('d-m-Y');
    }
}
