PHP code example of whitecube / laravel-prices
1. Go to this page and download the library: Download whitecube/laravel-prices 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/ */
whitecube / laravel-prices example snippets
return [
'model' => \App\Models\CustomPriceModel::class,
];
use Whitecube\LaravelPrices\HasPrices;
class Product extends Model
{
use HasPrices;
}
$product->price = new Price(amount: 50, currency: 'EUR');
use Whitecube\LaravelPrices\Models\Price;
$product->price = new Price(
amount: 50,
currency: 'EUR',
type: 'selling',
activated_at: now()->addWeek()
);
$product->setPrice(
amount: 50,
currency: 'EUR',
type: 'selling',
activated_at: now()->addWeek()
);
$product->price = new Price(
minor: 5000,
currency: 'EUR',
type: 'selling',
activated_at: now()->addWeek()
);
$price = $product->price;
$buying_price = $product->prices()->current()->where('type', 'buying')->first();
$buying_price->toObject();
$product->prices()->current()->first();
$product->prices()->effectiveAt(now()->subWeek())->first();
$product->prices()->oneOffs()->get();
shell
php artisan vendor:publish --tag=prices-config