Introducing nameable
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
I've been itching to give Laravel's new custom casting feature a go since it landed in 7.0. Cleaning up some of the full_name
and initials
attribute accessors I've got sprinkled through my apps looked like a good opportunity to port Basecamp's name_of_person
library to Larave.
So I'm excited to introduce nameable for Laravel.
Nameable is a custom cast for your Eloquent models that gives you a number of handy accessors for your user's names. Getting started is really easy - just use the Nameable
cast.
Now the name
attribute on your model will be an instance of Watson\Nameable\Name
, giving you shorthand accessors to
Have a look at the repo for more information and to get started.