<?php

namespace App\Models;

use App\Models\User\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ReportFilterPreset extends Model {
    protected $fillable = ['user_id', 'name', 'model_type', 'filters'];

    protected $casts = ['filters' => 'array'];

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

    public function scopeForUser(Builder $query, int $userId): Builder {
        return $query->where('user_id', $userId);
    }
}
