jn-devops/products
最新稳定版本:v1.4.2
Composer 安装命令:
composer require jn-devops/products
包简介
Homeful Products Package
关键字:
README 文档
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:
priceappraised_valuepercent_down_paymentdown_payment_termpercent_miscellaneous_feesprocessing_fee
- Loan-Related:
balance_payment_interest_ratebalance_payment_termmortgage_redemption_insurance_feeincome_requirement_multiplierpercent_gross_monthly_income
- Eligibility:
max_agemaximum_paying_age
- Status & Media:
status_codekey_locationdigital_assetsphased_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. 🏡✨
统计信息
- 总下载量: 3.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-11