<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * User-saved filter combo. e.g. "all my prod web servers with cpu > 70%".
 *
 * Shared views (`is_shared = true`) appear in everyone's view list so the
 * team can standardise on canonical filters ("Today's outages").
 */
class SavedView extends Model {
    use HasFactory;
    protected $fillable = ['user_id','name','page','filters','is_shared','is_pinned','order'];
    protected $casts = ['filters' => 'array', 'is_shared' => 'boolean', 'is_pinned' => 'boolean'];
    public function user(): BelongsTo { return $this->belongsTo(User::class); }
}
