<?php

namespace App\Models;

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

class ApiTokenBearer extends Model
{
    use SoftDeletes;
    use Prunable;

    protected $table = 'api_token_bearer';

    protected $fillable = [
        'bearer',
        'expiration_at',
        'token_id'
    ];

    public function prunable() {
        // Mark anything older than four months as a candidate for pruning.
        return static::where('expiration_at', '<=', now()->subHour())->orWhere('deleted_at', '<=', now()->subHour());
    }
}
