This package provides Laravel support for karkowg/bit-flag.
Requires PHP 7.4 and Laravel 8.x
⚡️ Installation
composer require karkowg/laravel-bit-flag
<?php
namespace App\BitFlags;
use Karkow\BitFlag\Laravel\BitFlag;
class CartStatus extends BitFlag
{
private const CHECKED_OUT = 1 << 0;
private const PAYED = 1 << 1;
private const SHIPPED = 1 << 2;
// ... other setters/getters
public function markAsPayed(): self
{
return $this->set(self::PAYED);
}
public function hasBeenPayed(): bool
{
return $this->has(self::PAYED);
}
}
// App\Services\CartService
$cartStatus = CartStatus::make();
if ($paymentSuccessful) {
$cartStatus->markAsPayed();
}
$cartStatus->hasBeenPayed(); //? true
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.