jn-devops / products
Homeful Products Package
Fund package maintenance!
Homeful
Installs: 2 029
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- jn-devops/common: ^1.1
- spatie/laravel-data: ^4.8
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
README
This package is part of the Homeful ecosystem and represents a robust Eloquent-based product model for real estate or housing-related systems. It supports a wide range of property and product-related fields and implements the ProductInterface
.
๐ฆ Product Model Overview
The Product
model captures both core product identity and extended metadata such as property location, pricing, appraisal, and requirements using the SchemalessAttributes
via the meta
field.
โ Implements:
ProductInterface
- Supports price casting using
Whitecube\Price
- Configurable with Laravel's environment and configuration system
๐งฉ Traits Used
HasAdditionalAttributes
This trait defines metadata-backed accessors/mutators using the SchemalessAttributes
package. Key functionalities include:
๐ Property Metadata Fields
- Basic Fields:
market_segment
,location
,destinations
,directions
,amenities
,facade_url
- Property Info:
project_location
,project_code
,property_name
,phase
,block
,lot
- Dimensions:
lot_area
,floor_area
,project_address
- Structure:
property_type
,unit_type
,house_type
- Financials:
price
appraised_value
percent_down_payment
down_payment_term
percent_miscellaneous_fees
processing_fee
- Loan-Related:
balance_payment_interest_rate
balance_payment_term
mortgage_redemption_insurance_fee
income_requirement_multiplier
percent_gross_monthly_income
- Eligibility:
max_age
maximum_paying_age
- Status & Media:
status_code
key_location
digital_assets
phased_out
Each field is encapsulated via custom getXXXAttribute()
and setXXXAttribute()
accessors/mutators, backed by JSON metadata.
๐๏ธ Model Details
Key Properties
Property | Type | Source |
---|---|---|
sku |
string | Eloquent |
name |
string | Eloquent |
brand |
string | Eloquent |
category |
string | Eloquent |
description |
string | Eloquent |
price |
Price | casts via PriceCast |
appraised_value |
Price | meta |
percent_down_payment |
float | meta |
down_payment_term |
int | meta |
percent_miscellaneous_fees |
float | meta |
processing_fee |
float | meta or fallback |
phased_out |
bool | meta |
๐ฅ Config Defaults (config/products.php)
return [ 'default' => [ 'processing_fee' => 10000, 'percent_dp' => 0.10, // 10% 'dp_term' => 12, // 12 months 'percent_mf' => 0.085, // 8.5% ], ];
๐งช Tests
Functional Coverage:
- Asserts all core and meta attributes are working as expected
- Verifies casting and type correctness (e.g., Price, float, int, string)
- Confirms that
ProductData::fromModel()
transformation works - Tests
updateOrCreate()
and interface compliance
expect($product->getAppraisedValue()->equals($product->appraised_value))->toBeTrue(); expect($product->getPercentDownPayment())->toBe($product->percent_down_payment);
๐งฌ Data Transformation
ProductData
The ProductData
class maps the Product
model into a normalized, transport-ready DTO using Spatie Laravel Data:
$data = ProductData::fromModel($product);
Provides direct mapping to all relevant fields like:
sku
,name
,brand
,description
, etc.- Financial metrics and interest/multiplier values
- Metadata-rich project and unit identifiers
๐ Conclusion
This package bridges the static nature of database tables and the flexibility needed for real estate product customization. By leveraging SchemalessAttributes
, it ensures adaptability without schema bloat.
Behold, a new you awaits โ in housing, and in code. ๐กโจ