src/Models/Database/Property.php
public function getProductValueModel($productId)
    {
        $dataType = ucfirst(strtolower($this->data_type));

        $method = 'productProperty' . $dataType . 'Value';

        $productPropertyModel = $this
                                        ->$method()
                                        ->whereProductId($productId)
                                        ->get();

        if ($productPropertyModel->count() == 0) {
            $valueClass = __NAMESPACE__ . '\\' . ucfirst($method);

            $valueModel = new $valueClass([
                'property_id' => $this->id,
                'product_id' => $productId
            ]);
        } else {
            $valueModel = $this->$method()->whereProductId($productId)->first();
        }

        return $valueModel;
    }
public function getProductValueModel($productId)
    {
        $dataType = ucfirst(strtolower($this->data_type));

        $method = 'productProperty' . $dataType . 'Value';

        $productPropertyModel = $this
                                        ->$method()
                                        ->whereProductId($productId)
                                        ->get();

        if ($productPropertyModel->count() == 0) {
            $valueClass = __NAMESPACE__ . '\\' . ucfirst($method);

            $valueModel = new $valueClass([
                'property_id' => $this->id,
                'product_id' => $productId
            ]);
        } else {
            $valueModel = $this->$method()->whereProductId($productId)->first();
        }

        return $valueModel;
    }
public function getProductValueModel ( $ productId ) { $ dataType = ucfirst ( strtolower ( $ this -> data_type ) ) ; $ method = 'productProperty' . $ dataType . 'Value' ; $ productPropertyModel = $ this -> $ method ( ) -> whereProductId ( $ productId ) -> get ( ) ; if ( $ productPropertyModel -> count ( ) == 0 ) { $ valueClass = __NAMESPACE__ . '\\' . ucfirst ( $ method ) ; $ valueModel = new $ valueClass ( [ 'property_id' => $ this -> id , 'product_id' => $ productId ] ) ; } else { $ valueModel = $ this -> $ method ( ) -> whereProductId ( $ productId ) -> first ( ) ; } return $ valueModel ; }
Get Product Property Value Model based by ProductID.

@param integer $productId
@return \Illuminate\Database\Eloquent\Model
Get Product Property Value Model based by ProductID .