Release Note v0.9

Bazar v0.9 is released. Let's walk through the most important things about this release.

This release contains a lots of BREAKING CHANGE. You might use the git compare tool to see every code change. For the complete list of changes, please read the changelog.

The Buyable Interface

In v0.9 we reworked the Cart/Order <-> Item <-> Product relations. Until now, Cart and Order models could hold only Product models using the Item pivot model.

We've added the Bazar\Contracts\Buyable interface, and instead of the Product type-restriction, we look for Buyable interface implementations.

The Buyable interface holds only the toItem method:

namespace App\Models;

use Bazar\Concerns\InteractsWithItemables;
use Bazar\Contracts\Buyable;
use Bazar\Contracts\Itemable;
use Bazar\Models\Item;
use Illuminate\Database\Eloquent\Model;

class Addon extends Model implements Buyable
{
    use InteractsWithItemables;

    public function toItem(Itemable $itemable, array $attributes = []): Item
    {
        return $this->items()->make([
            'price' => ...,
            'name' => ...,
        ])->setAttribute('buyable', $this);
    }
}
use Bazar\Support\Facades\Cart;

// The new addItem() method signature
Cart::addItem(Buyable $buyable, float $quantity, array $properties);