<?php

namespace App\Models;

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

/**
 * @property int $id
 * @property int $user_id
 * @property string $type
 * @property string|null $subject
 * @property string|null $body
 * @property int|null $rating
 * @property string|null $app_version
 * @property string|null $platform
 * @property array<string, mixed>|null $meta
 */
class UserFeedback extends Model
{
    protected $table = 'user_feedbacks';

    public const TYPE_BUG = 'bug';

    public const TYPE_FEEDBACK = 'feedback';

    public const TYPE_RATING = 'rating';

    protected $fillable = [
        'user_id',
        'type',
        'subject',
        'body',
        'rating',
        'app_version',
        'platform',
        'meta',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'rating' => 'integer',
            'meta' => 'array',
        ];
    }

    /** @return BelongsTo<User, UserFeedback> */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
