All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Laravel 9 support.
- Version 2.0.0 released.
- The
Presenter
class now has atoArray()
method which will return ALL presentables as an array (including hidden presentables).
- Model classes can now specify presentable classes by passing the attribute name and the class path to the
$presentables
array attribute. - If the class cannot be found, a new
InvalidPresentableClass
exception will be thrown. - Added the ability to hide presenters from the array by implementing the
IsHidden
interface. - Added the presenter options. Options can be passed to presenter classes by passing an array to each item in the
$presentables
array. - Added the ability for presenter classes to have access to the attribute from the
$presentables
array. - Default presentables can be added to the
presentable
config file and will be added to allIsPresentable
classes.
- The signature for the
Presenter
class has been changed. The firstModel
parameter has been removed as it was never actually used. - The
IsPresentable
trait has been updated to reflect the above change. - This is a potential breaking change if the
Presenter
class is overridden.
- Included a configuration file. The default array key (
presentable
) can now be configured. - Some simplification in the
IsPresentable
trait. - Protected method
getBaseAttrinbutes
has been renamed togetOriginalAttributes
.
- Renamed the
present()
topresentable()
so that it now matches the key name when converting the model to an array. - Added
getBaseAttributes()
method to theIsPresentable
trait which will now test for the existence of atoArray
method on the parent class before trying to callparent::toArray()
. This might allow for the use ofIsPresentable
outside of Laravel projects (not tested). - Updated the
toArray
method onIsPresentable
to get an array of attributes from thegetBaseAttributes
method.