<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
    protected $fillable = [
        'registration_id',
        'comment',
    ];

    /*
    |---------------------------
    | Relationships
    |---------------------------
    */

    // Comment belongs to a student
    public function registration()
    {
        return $this->belongsTo(Registration::class);
    }

    /*
    |---------------------------
    | Helper methods
    |---------------------------
    */

    // Optional: short preview for UI
    public function getPreviewAttribute()
    {
        return strlen($this->comment) > 50
            ? substr($this->comment, 0, 50) . '...'
            : $this->comment;
    }
}