App\Models\Store\Product::types PHP Method

types() public method

public types ( )
    public function types()
    {
        $mappings = $this->typeMappings();
        if ($mappings === null) {
            return;
        }
        if ($this->types !== null) {
            return $this->types;
        }
        $currentMapping = $mappings[strval($this->product_id)];
        $this->types = [];
        foreach ($mappings as $product_id => $mapping) {
            foreach ($mapping as $type => $value) {
                if (!isset($this->types[$type])) {
                    $this->types[$type] = [];
                }
                $mappingDiff = array_diff_assoc($mapping, $currentMapping);
                if (count($mappingDiff) === 0 || count($mappingDiff) === 1 && isset($mappingDiff[$type])) {
                    $this->types[$type][$value] = intval($product_id);
                }
            }
        }
        return $this->types;
    }