<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

// ══════════════════════════════════════════════════════════════════
//  InPractice — SolutionRating Model
//  Table: case_solution_ratings
//
//  One rating (1–5) per member per solution.
//  Unique constraint enforced at DB level.
// ══════════════════════════════════════════════════════════════════

class SolutionRating extends Model
{
    protected $table = 'case_solution_ratings';

    protected $fillable = [
        'solution_id',
        'user_id',
        'rating',
    ];

    protected $casts = [
        'rating' => 'integer',
    ];

    // ── Relationships ──────────────────────────────────────────

    public function solution(): BelongsTo
    {
        return $this->belongsTo(MemberSolution::class, 'solution_id');
    }

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