Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 10
PerVariantForm
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 10
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 handle
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 9
<?php
namespace Mtc\Shop\PriceMethods\Listeners;
use Mtc\Core\Events\Admin\ItemLoading;
use Mtc\Shop\Variant;
use Mtc\Shop\PriceMethods\PerVariant;
use Mtc\Shop\PriceMethods\Models\PricePerVariant;
class PerVariantForm
{
    public function __construct()
    {
    }
    public function handle(ItemLoading $event)
    {
        // Don't run if this isn't the variant page.
        if (
            get_class($event->model) != Variant::class ||
            $event->model->product->price_method != PerVariant::class
        ) {
            return;
        }
        // Now we get the prices back for this item.
        $prices = PricePerVariant::whereVariantId($event->model->id)
            ->orderBy('quantity', 'ASC')
            ->orderBy('price', 'ASC')
            ->get();
        // Echo out a view for this page.
        echo view('shop::admin.price_methods.per_variant')->with(compact('prices'));
    }
}