Files
YNWA Fawzy 8a290a0d09 - Added Argos UK to the list of stores
- Added groups, where you can set bunch of items with identified unique keys to get the lowest price on group of products. ( think of it like building your own PC, you add multiple CPUs, and GPUs and the program will notify you when the combination reaches a desired price)
- Added 2FA Support to the system  (Optional)
- Make Sidebar collapsable
- Fix name is too short which results to not be saved
- Fix a bug where product can be duplicated from amazon stores
2024-01-16 15:53:45 +04:00

54 lines
1.4 KiB
PHP

<?php
namespace App\Filament\Resources\GroupResource\Pages;
use App\Classes\GroupHelper;
use App\Classes\MainStore;
use App\Classes\URLHelper;
use App\Filament\Resources\GroupResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class EditGroup extends EditRecord
{
protected static string $resource = GroupResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
protected function handleRecordUpdate(Model $record, array $data): Model
{
if (Arr::exists($this->data , "products"))
GroupHelper::update_products_records($record->id , $data["products"]);
if ($this->data["url_products"]){
$urls=$this->data["url_products"];
foreach ($urls as $single_url){
if($single_url["url"]){
$url=new URLHelper($single_url['url']);
if (!MainStore::validate_url($url))
$this->halt();
else{
$product_id=MainStore::create_product($url);
GroupHelper::update_group_product_record($this->record->id, $product_id, $single_url["key"]);
}
}
}
}
return parent::handleRecordUpdate($record, $data); // TODO: Change the autogenerated stub
}
}