50 lines
1.0 KiB
PHP
50 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
|
|
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);
|
|
}
|
|
|
|
public function reports(): MorphMany
|
|
{
|
|
return $this->morphMany(Report::class, 'reportable');
|
|
}
|
|
|
|
public function moderationCase(): MorphOne
|
|
{
|
|
return $this->morphOne(ModerationCase::class, 'caseable');
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'id' => 'string',
|
|
'rating' => 'integer',
|
|
];
|
|
}
|
|
}
|