Files
LaravelShoppingcart/tests/Fixtures/BuyableProduct.php
Andrew Minion f5b9900949 add missing text fixture method
Followup to 3f246caf1a
2022-03-03 21:41:01 -06:00

77 lines
1.6 KiB
PHP

<?php
namespace Gloudemans\Tests\Shoppingcart\Fixtures;
use Gloudemans\Shoppingcart\CartItemOptions;
use Gloudemans\Shoppingcart\Contracts\Buyable;
use Illuminate\Database\Eloquent\Model;
use Money\Currency;
use Money\Money;
class BuyableProduct extends Model implements Buyable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'id',
'name',
'title',
'description',
'price',
'currency',
'weight',
];
protected $attributes = [
'id' => 1,
'name' => 'Item name',
'price' => 1000,
'currency' => 'USD',
'weight' => 0,
];
/**
* Get the identifier of the Buyable item.
*
* @return int|string
*/
public function getBuyableIdentifier(CartItemOptions $options)
{
return $this->id;
}
/**
* Get the description or title of the Buyable item.
*
* @return string
*/
public function getBuyableDescription(CartItemOptions $options): ?string
{
return $this->name;
}
/**
* Get the price of the Buyable item.
*/
public function getBuyablePrice(CartItemOptions $options): Money
{
return new Money($this->price, new Currency($this->currency));
}
/**
* Get the price of the Buyable item.
*/
public function getBuyableWeight(CartItemOptions $options): int
{
return $this->weight;
}
public function getBuyableTaxRate(CartItemOptions $options): float
{
return $this->tax_rate;
}
}