All notable changes to laravel-dynamic-resources
will be documented in this file.
- ✨ New modular mode system with chainable methods
- 🔌 Support for dynamic mode combinations using
with
andwithout
prefixes - 🔗 Ability to combine multiple modes in both single resources and collections
- 💫 Automatic mode inheritance for nested resources
- 📚 Comprehensive documentation for new features
- 🏗️ Refactored mode handling to support multiple active modes
- 🔄 Updated
fields()
method to use array keys for modes - ⚡ Improved performance by merging fields from active modes
- 🔧 Modified magic method handling for better extensibility
- Changed the structure of the
fields()
method to use mode names as array keys - Removed single mode limitation in favor of multiple mode support
- Updated method signatures for better type safety and PHP 8.2 compatibility
protected function fields(): array
{
return match($this->mode) {
'minimal' => [
'id',
'username',
],
'minimal-with-avatar' => [
'id',
'username',
'profile',
],
default => [
'id',
'username',
]
};
}
protected function fields(): array
{
return [
'minimal' => [
'id',
'username',
],
'avatar' => [
'profile' => UploadResource::make($this->channel->profile)->minimal(),
],
'default' => [
'id',
'username',
]
];
}
// Old way (0.0.x)
UserResource::make($user)->setMode('minimal-with-avatar');
// New way (0.1.x)
UserResource::make($user)
->minimal()
->withAvatar();
- 🐛 Fixed mode inheritance in nested resources
- 🔒 Improved type safety throughout the codebase
- ♻️ Better handling of default modes when others are removed
- 🧹 Cleaned up method signatures for better IDE support
For more details about the changes and new features, please refer to the updated README.md file.