53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Customer\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Modules\Restaurant\Models\Customer;
|
|
use Modules\Restaurant\Models\FoodItem;
|
|
|
|
class Review extends Model
|
|
{
|
|
protected $fillable = [
|
|
'restaurant_id',
|
|
'customer_id',
|
|
'food_item_id',
|
|
'rating',
|
|
'comment',
|
|
'is_approved',
|
|
'is_active',
|
|
'likes_count',
|
|
'reported_count',
|
|
'created_at',
|
|
'updated_at',
|
|
'deleted_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_approved' => 'boolean',
|
|
'is_active' => 'boolean',
|
|
'rating' => 'integer',
|
|
];
|
|
|
|
public const TABLE_NAME = 'reviews';
|
|
|
|
protected $table = self::TABLE_NAME;
|
|
|
|
/* ================= Relationships ================= */
|
|
|
|
public function images()
|
|
{
|
|
return $this->hasMany(ReviewImage::class)->select('id', 'review_id', 'image_path', 'position');
|
|
}
|
|
|
|
public function foodItem()
|
|
{
|
|
return $this->belongsTo(FoodItem::class)->select('id', 'name', 'image');
|
|
}
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
}
|