<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;

class PasswordHistory extends Model
{
    use Prunable;

    protected $fillable = ['user_id', 'password'];

    public function prunable(): Builder
    {
        return self::query()->where('created_at', '<=', now()->subDays(365));
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
