1. Go to this page and download the library: Download marshmallow/products library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
marshmallow / products example snippets
use Marshmallow\Product\Models\Product;
use Marshmallow\Product\Observers\ProductObserver;
public function boot()
{
Product::observe(ProductObserver::class);
}
use Marshmallow\Product\Models\Product;
$product = Product::factory()->create([
'name' => 'Example product',
]);
// Eager load the common relationships to prevent N+1 queries.
$products = Product::active()->withRelationships()->get();
foreach ($products as $product) {
$product->fullname(); // human readable name
$product->freeStock(); // amount purchasable right now
$product->getAvailability(); // Product::IN_STOCK | OUT_OF_STOCK | PREORDER
$product->getCondition(); // 'new'
$product->route(); // route('product.detail', $product)
if ($product->hasImage()) {
$product->firstImagePath();
}
}