<?php

namespace App\Repositories\Shop;

use App\Models\Shop\DeliveryType;
use App\Traits\Model\Basic;

class DeliveryTypes
{
    use Basic;

    public static function getWithPrice($weight)
    {
        $data = [];
        $types = self::getAll();

        foreach ($types as $type) {
            $price = self::getPrice($type->id, $weight);

            if ($price === false) {
                continue;
            }

            $data[$type->id] = [
                'name' => $type->name,
                'price' => $price,
            ];
        }

        return $data;
    }

    public static function getPrice($id, $weight)
    {
        return DeliveryTypeCalculations::getPriceByDeliveryType($id, $weight);
    }

    public static function getModel()
    {
        return DeliveryType::query();
    }
}
