Checks product stock level against threshold returns boolean low-stock flag.
// Source: https://github.com/angkosal/laravel-pos | License: MIT | Copyright 2023 [Laravel-POS contributors](https://github.com/angkosal/laravel-pos/graphs/contributors)
// Provided via justclaw.it.com; keep this notice with the code.
<?php
namespace App\Traits;
use Illuminate\Support\Facades\DB;
trait ProductScopes
{
/**
* Check if product is low stock.
*/
public function isLowStock(): bool
{
return $this->quantity < 10;
}
/**
* Check if product is out of stock.
*/
public function isOutOfStock(): bool
{
return $this->quantity === 0;
}
/**
* Scope for active products.
*/
public function scopeActive($query)
{
return $query->where('status', true);
}
/**
* Scope for low stock
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key