Files
YNWA Fawzy 500b716652 Features:
- add Ajio test
- add myntra test
- add nykaa test
- add snapdeal test
- add tataCliq test

Fixes:
- fix amazon poland price only getting thousands.
- fix single product store view.

Enhancements:
- add scroll to top page when page has changed.
- change layout for product page.
- preparing api for mobile application

Took 7 hours 52 minutes
2025-01-01 22:09:04 +04:00

72 lines
1.7 KiB
PHP

<?php
namespace App\Models;
use App\Enums\StatusEnum;
use App\Observers\ProductObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[ObservedBy(ProductObserver::class)]
class Product extends Model
{
use HasFactory;
protected $fillable=[
"name",
"image",
"status",
"favourite",
"stock",
"snoozed_until",
"max_notifications",
"lowest_within",
"only_official",
"walmart_ip",
"argos_id",
];
protected $casts=[
'status'=>StatusEnum::class,
'favourite' => 'boolean'
// 'stores.pivot.price'=>Money::class,
// 'stores.pivot.price'=>Money::class,
// 'stores.pivot.price'=>Money::class,
// 'stores.pivot.notify_price'=>Money::class,
// 'stores.pivot.shipping_price'=>Money::class,
// 'stores.pivot.updated_at'=>'datetime',
];
public function categories()
{
return $this->belongsToMany(Category::class)->withTimestamps();
}
public function stores()
{
return $this->belongsToMany(Store::class)->withTimestamps()->withPivot([
"id",
'price',
'highest_price',
'lowest_price',
'notify_price',
'notify_percentage',
'rate',
'number_of_rates',
'seller',
'shipping_price',
'updated_at',
'add_shipping',
]);
}
public function product_stores(): HasMany
{
return $this->hasMany(ProductStore::class);
}
}