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
78 lines
1.8 KiB
PHP
78 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Casts\Money;
|
|
use App\Enums\StatusEnum;
|
|
use App\Observers\StoreObserver;
|
|
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
|
#[ObservedBy(StoreObserver::class)]
|
|
class Store extends Model
|
|
{
|
|
use HasFactory ;
|
|
|
|
protected $fillable=[
|
|
"deleted_at",
|
|
"name",
|
|
"domain",
|
|
"image",
|
|
"slug",
|
|
"status",
|
|
"tabs",
|
|
"currency_id",
|
|
];
|
|
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status'=>StatusEnum::class,
|
|
'price'=>Money::class,
|
|
'used_price'=>Money::class,
|
|
'lowest_price'=>Money::class,
|
|
'highest_price'=>Money::class,
|
|
'notify_price'=>Money::class,
|
|
'notify_percentage'=>Money::class,
|
|
'shipping_price'=>Money::class,
|
|
'pivot.updated_at'=>'datetime',
|
|
];
|
|
}
|
|
|
|
|
|
public function currency(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(Currency::class);
|
|
}
|
|
|
|
public function products()
|
|
{
|
|
return $this->belongsToMany(Product::class)->withTimestamps()->withPivot([
|
|
"id",
|
|
//data
|
|
'price',
|
|
'notify_price',
|
|
'notify_percentage',
|
|
'rate',
|
|
'number_of_rates',
|
|
'seller',
|
|
'shipping_price',
|
|
'updated_at',
|
|
//extra settings
|
|
'add_shipping',
|
|
//ebay
|
|
'remove_if_sold',
|
|
'ebay_id',
|
|
]);
|
|
}
|
|
|
|
public function product_stores(): HasMany
|
|
{
|
|
return $this->hasMany(ProductStore::class);
|
|
}
|
|
}
|