Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 10 |
| PerProductForm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 10 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| handle | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 9 |
|||
| <?php | |
| namespace Mtc\Shop\PriceMethods\Listeners; | |
| use Mtc\Core\Events\Admin\ItemLoading; | |
| use Mtc\Shop\Product; | |
| use Mtc\Shop\PriceMethods\PerProduct; | |
| use Mtc\Shop\PriceMethods\Models\PricePerProduct; | |
| class PerProductForm | |
| { | |
| public function __construct() | |
| { | |
| } | |
| public function handle(ItemLoading $event) | |
| { | |
| // Don't run if this isn't the product page. | |
| if ( | |
| get_class($event->model) != Product::class || | |
| $event->model->price_method != PerProduct::class | |
| ) { | |
| // Don't return false here as it stops throwing the rest of the event queue. | |
| return; | |
| } | |
| // Now we get the prices back for this item. | |
| $prices = PricePerProduct::whereProductId($event->model->id) | |
| ->orderBy('quantity', 'ASC') | |
| ->orderBy('price', 'ASC') | |
| ->get(); | |
| // Echo out a view for this page. | |
| echo view('shop::admin.price_methods.per_product')->with(compact('prices')); | |
| } | |
| } |