laravel-traits maintained by ludo237
Laravel Traits
A set of useful traits for Laravel.
Why
Laravel is a great framework and Eloquent is a piece of art in terms of ActiveRecord ORM but it lacks some useful quirks and features that I decided to integrated trough a set of Traits.
What is a trait?
In PHP A trait is a a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies. The semantics of the combination of Traits and classes is defined in a way which reduces complexity,and avoids the typical problems associated with multiple inheritance and Mixins. Source
How to use this package
Simple enough, just grab it from composer composer require ludo237/laravel-traits and it's done. Now you can use the traits inside your eloquent models or wherever you needs them
What is included
With time things can change current traits are:
Bannableinject logic into models to interact with abanned_atcolumn.CanBeActivateadd logic to a model in order to activate/deactivate it using a timestamp columnExposeTablePropertiesit allows the model to expose publicly the table name, the primary key name and his type.HasSlugautomatically creates the logic behind aslugcolumn for your model.InteractsWithApiautomatically set the api_key for the current model following Laravel standards.OwnedByUserAutomatically set the current model as owned by the User modelBenchmarkableStart/Stop a timer to benchmark your Artisan Commands
How to Contribute
Please see the contribute file for more information