laravel-shop/src
Fabian @ Blax Software 8eb1802ef8 feat: promote IsLoanableProduct to MayBeLoanableProduct on Product
Renames the host-attached IsLoanableProduct trait to MayBeLoanableProduct
and mixes it directly into Product, matching the existing MayBePoolProduct
shape. Hosts opt in with a single DEFAULT_TYPE constant — no more manual
`use ...Trait` ceremony to forget:

    class Book extends Product
    {
        public const DEFAULT_TYPE = ProductType::LOANABLE;
    }

The boot hook reads DEFAULT_TYPE on the concrete class and only applies
the LOANABLE creating-defaults (type, status, is_visible, manage_stock)
when it matches; type-specific helpers (checkOutTo, total_quantity,
available_quantity) early-out via isLoanable() so they're harmless on
non-loanable products. checkOutTo now throws NotLoanableProductException
when called on the wrong type, mirroring NotPoolProductException.

Also fixes total_quantity for the loan lifecycle: previously summed every
INCREASE entry in product_stocks, which inflated the displayed total
after each loan cycle because returns fire increaseStock(). Now reports
physical inventory as availableStock + activeLoans.

README gains a Testing section that surfaces the current phpunit summary
line, plus passing and assertion-count badges linking to it.
2026-05-16 12:17:38 +02:00
..
Console/Commands feat: Enhance traits with strict types and improve method signatures 2026-05-15 20:26:24 +02:00
Contracts feat: Enhance traits with strict types and improve method signatures 2026-05-15 20:26:24 +02:00
Enums feat: Enhance traits with strict types and improve method signatures 2026-05-15 20:26:24 +02:00
Events feat: Enhance traits with strict types and improve method signatures 2026-05-15 20:26:24 +02:00
Exceptions feat: promote IsLoanableProduct to MayBeLoanableProduct on Product 2026-05-16 12:17:38 +02:00
Facades feat: Enhance traits with strict types and improve method signatures 2026-05-15 20:26:24 +02:00
Http feat: Enhance traits with strict types and improve method signatures 2026-05-15 20:26:24 +02:00
Models feat: promote IsLoanableProduct to MayBeLoanableProduct on Product 2026-05-16 12:17:38 +02:00
Services feat: Enhance traits with strict types and improve method signatures 2026-05-15 20:26:24 +02:00
Traits feat: promote IsLoanableProduct to MayBeLoanableProduct on Product 2026-05-16 12:17:38 +02:00
ShopServiceProvider.php feat: Enhance traits with strict types and improve method signatures 2026-05-15 20:26:24 +02:00