<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Deliverable extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $guarded = [];
    protected $casts = [
        'delivered_at' => 'datetime:Y-m-d',
    ];

    public function milestone()
    {
        return $this->belongsTo(Milestone::class);
    }

    public function deliver()
    {
        $this->update([
            'delivered_at' => now(),
        ]);
        return $this;
    }
}
