<?php

namespace App\Models;

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

class PostReviews extends Model
{
    use HasUlids;

    protected $fillable = [
        'meal_post_id',
        'rating',
        'comment',
        'user_id',
    ];

    public function mealPost(): BelongsTo
    {
        return $this->belongsTo(MealPosts::class, 'meal_post_id');
    }

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

    protected function casts(): array
    {
        return [
            'id' => 'string',
            'rating' => 'integer',
        ];
    }
}
