mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
28 lines
576 B
PHP
28 lines
576 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\Plan;
|
|
|
|
class PlanService
|
|
{
|
|
public $plan;
|
|
|
|
public function __construct(int $planId)
|
|
{
|
|
$this->plan = Plan::lockForUpdate()->find($planId);
|
|
}
|
|
|
|
public function incrementInventory(): bool
|
|
{
|
|
if ($this->plan->inventory_limit !== NULL) return true;
|
|
return $this->plan->increment('inventory_limit');
|
|
}
|
|
|
|
public function decrementInventory(): bool
|
|
{
|
|
if ($this->plan->inventory_limit !== NULL) return true;
|
|
return $this->plan->decrement('inventory_limit');
|
|
}
|
|
}
|