Releases: tpg/is-presentable
v2.0.1
v2.0.0
Version 2 brings something completely new. Presentables can now be defined as classes to make the more reusable. The old way (as in the presentable accessor methods) still works fine and there is no intention of removing that feature. This version is backward compatible, but if you encounter any problems please log an issue.
There are a number of changes which could cause problems if you're extended IsPresentable. The only one I can think of that may cause some frustration is the protected array that stored presentables on your models has been renamed from $presenters
to $presentables
.
I've also fleshed out the readme a lot for this version so there's plenty of detail on how to use IsPresentable.
v2.0.0-beta.3
Added a toArray()
method to the Presenter
class. This can be used like this:
$presentables = $user->presentable()->toArray();
v2.0.0-beta.1
Version 2 brings a new way to create presentables with a lot of flexibility and less duplication.
I've tried to keep as much backward compatibility as possible, so version 1 users should be able to upgrade without making any changes to their code. If you're overriding stuff, then there might be some things that are going to break.
Version 2 introduces a number of new features:
- Presentable classes are a handy way to allow for the reuse of presentables.
- Pass arbitrary data into presentable classes so you could have a single class that can be used to present different attributes.
- Default presentables can be set in the configuration file.
- Presentable classes can be marked as hidden which will remove them from the array when using
toArray
on a model.
v1.1.0
Made a change to the Presenter
class that removes the requirement of a Laravel Model
class. This should help make the package a little less "Laravel Model specific".
v1.0.0
Version 1! Yeah!
Okay, it's not that amazing. Is-presentable is fairly basic. It probably should have been tagged ages ago. Anyway.
Added the ability to configure the key used when casting the model as an array.
v0.2.0
- Renamed the
present()
method on theIsPresentable
trait topresentable()
so that its the same name as thepresentable
key on the array when callingtoArray()
. - Potentially the library could work outside of a Laravel project. The
toArray()
method has an update that will now check for the existence of atoArray()
method on the parent first. You could override thegetBaseAttributes()
method as well to return whatever attributes your model needs to return.
v0.1.0
There's not much to this thing. It's really just a packaged version of something I've been doing for a while now. Just to make it simply to include in other projects.
If there's any new ideas for this, I'm keen to hear them.