QueenFruits/Backend/app/Models/ProductLike.php

45 lines
914 B
PHP

<?php
namespace App\Models;
use App\Traits\Multitenantable;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
class ProductLike extends Model
{
use Multitenantable;
protected $primaryKey = 'uuid';
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = [
'uuid',
'tenant_id',
'customer_id',
'product_id',
'is_like'
];
protected $casts = [
'is_like' => 'boolean',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
protected function serializeDate(DateTimeInterface $date)
{
return $date->format('Y-m-d H:i:s');
}
public function customer() {
return $this->belongsTo(Customer::class, 'customer_id', 'uuid');
}
public function product() {
return $this->belongsTo(Product::class, 'product_id', 'uuid');
}
}