mirror of https://github.com/4xmen/xshop.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
461 B
PHP
22 lines
461 B
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Models\Price;
|
|
use App\Models\Product;
|
|
|
|
class ProductObserver
|
|
{
|
|
//
|
|
public function updated(Product $product){
|
|
\Log::info('product update');
|
|
if ($product->wasChanged('price') && $p->price != null){
|
|
\Log::info('product price update');
|
|
$p = new Price();
|
|
$p->product_id = $product->id;
|
|
$p->price = $product->price;
|
|
$p->save();
|
|
}
|
|
}
|
|
}
|