Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 6 |
| UpdateSortPrice | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 6 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| handle | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 5 |
|||
| <?php | |
| namespace Mtc\Shop\Listeners; | |
| use Mtc\Shop\Events\PriceUpdated; | |
| use Mtc\Shop\Product; | |
| class UpdateSortPrice | |
| { | |
| /** | |
| * Create the event listener. | |
| * | |
| * @return void | |
| */ | |
| public function __construct() | |
| { | |
| // | |
| } | |
| /** | |
| * Handle the event. | |
| * | |
| * @param PriceUpdated $event | |
| * @return void | |
| */ | |
| public function handle(PriceUpdated $event) | |
| { | |
| // Having to use DB as otherwise the save event is triggered, | |
| // which causes a recursive loop. | |
| \DB::table($event->product->getTable()) | |
| ->whereId($event->product->id) | |
| ->update([ | |
| 'sort_price' => $event->product->price->perProduct(), | |
| ]); | |
| } | |
| } |