isLowStock (ProductScopes.php)

laravel-pos · inventory-check, stock-monitoring, query-scope, threshold-alert, pos

Checks product stock level against threshold returns boolean low-stock flag.

<?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 products.
     */
    public function scopeLowStock($query)
    {
        return $query->where('quantity', '<', 10);
    }

    /**
     * Scope for best selling products (total sold > 10).
     */
    public function scopeBestSelling($

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key