<?php

namespace App\Models;

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

class MobileSyncLog extends Model
{
    use Prunable;

    public $timestamps = false;

    /**
     * Get the prunable model query.
     */
    public function prunable(): Builder
    {
        return self::query()->where('synced_at', '<=', now()->subDays(30));
    }

    protected $fillable = [
        'user_id',
        'platform',
        'device_model',
        'app_version',
        'ip_address',
        'synced_at',
    ];

    protected $casts = [
        'synced_at' => 'datetime',
    ];

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