41 lines
978 B
PHP
41 lines
978 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Repositories\ProductRepositoryInterface;
|
|
|
|
class ProductService extends ServiceBase
|
|
{
|
|
public function __construct(ProductRepositoryInterface $Repository)
|
|
{
|
|
parent::__construct();
|
|
$this->Repository = $Repository;
|
|
// $this->setRelation('contact','productGroup');
|
|
}
|
|
|
|
public function updatePrice($id, float $price): bool
|
|
{
|
|
if (! $this->Repository->updatePrice($id, $price)) {
|
|
$this->error->add('Update', 'Nem sikerült az ár módosítása!');
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function update($id, array $data): bool
|
|
{
|
|
$changed = $this->Repository->checkIsChanged($id, $data);
|
|
if ($changed) {
|
|
if (! $this->Repository->update($id, $data)) {
|
|
$this->error->add('Update', 'Nem sikerült a módosítás!');
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|