Add "shopavel/products": "1.0.*"
to your composer.json
and run composer update
.
This package is required by shopavel/shop
, you will not normally have to specifically require this package.
In app/config/app/php
, add the provider:
'providers' => array(
// ...
'Shopavel\Products\ProductsServiceProvider',
),
And the alias:
'aliases' => array(
// ...
'Product' => 'Shopavel\Products\Product',
)
You can use the Product
alias to access the product eloquent model, e.g. Product::find(1)
;
Prices
There are several types of price associated with a product.
$product = Product::find(1);
foreach ($product->getPrices() as $price)
{
echo $price->type . ': ' . $price->price;
}
You can access a specific price using:
echo $product->getPrice('retail');
Create a new product
$product = new Product;
$product->name = 'Foo';
app('product.create')->create($product);
All Shopavel packages are open-sourced software licensed under the MIT license