Add a custom attribute to a Laravel / Eloquent model on load?
The problem is caused by the fact that the Model‘s toArray() method ignores any accessors which do not directly relate to a column in the underlying table. As Taylor Otwell mentioned here, “This is intentional and for performance reasons.” However there is an easy way to achieve this: class EventSession extends Eloquent { protected $table=”sessions”; … Read more