Add polymorphic type references system for efficient integer-based storage
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1054,6 +1054,25 @@ Details: `php artisan rsx:man file_upload`
|
||||
|
||||
---
|
||||
|
||||
## POLYMORPHIC TYPE REFERENCES
|
||||
|
||||
Polymorphic `*_type` columns (fileable_type, taskable_type, etc.) store BIGINT integers in the database for efficiency. The framework maps between integer IDs and class names transparently.
|
||||
|
||||
```php
|
||||
// Model: Declare type ref columns
|
||||
protected static $type_ref_columns = ['fileable_type'];
|
||||
|
||||
// Usage: Code works with class name strings - conversion is automatic
|
||||
$attachment->fileable_type = 'Contact_Model'; // Stored as integer in DB
|
||||
echo $attachment->fileable_type; // Reads as 'Contact_Model'
|
||||
```
|
||||
|
||||
**Simple Names Only**: Always use `class_basename($model)`, never `get_class($model)` (FQCNs)
|
||||
|
||||
Details: `php artisan rsx:man polymorphic`
|
||||
|
||||
---
|
||||
|
||||
## AJAX ENDPOINTS
|
||||
|
||||
```php
|
||||
|
||||
Reference in New Issue
Block a user