mirror of
https://github.com/Cybrarist/Discount-Bandit.git
synced 2026-11-24 19:49:54 +01:00
- fix type when filtering product by price met target. - fix the lowest price was overridden if price wasn't crawled. - fix store tabs not working - fix some european amazon using "." as thousands separator. - keep last 3 days of logs only. - added volume to .env to fix 2FA not working after restarting container - added volume for database - New Stores: - best buy New Features: - add other users to the system and manage their tokens. - add telegram notification. - add percentage drop. - robot detection for amazon ( if the system was detected as robot, it will stop executing and try the next product, the same product that was blocked will be crawled again in the next batch) Took 6 hours 50 minutes
71 lines
1.7 KiB
PHP
71 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,
|
|
// '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);
|
|
}
|
|
}
|