Useful classes I use for Laravel projects
Want to see the current package in action, have a look at my starter project. Laravel Starter Project
Documentation is in progress
What it includes
Generate unique Slug
Model to get all the activities in the database.
Model that use the LogsActivity, ModifyBy traits and have the messages variable. (The base admin model, to get the modify by and activities per model)
Base Website Navigation. Title-Url Attribute helper, Gets the parent, generate the complete url (based on parent)
Base Admin Navigation. Helper functions to generate complete url, get all his parents.
Add the 'active_from, active_to'. Example: You have banners on your website and would to set the active period. This will by default set it active forever, or you can specify the from and to dates, and then you can Model::active()
If your model has an 'image' column and you have a thumb image, this trait will assume your thumb is the same name just with a '-tn' extension, So it saves you a image_thumb column and to create that 'attribute' function on your model.
When a model triggers the created, updated, deleted event it will log an activity with the before and after values.
On creating, updating, deleting. It will set the current logged in user id.
Gives you the recursive parent functionality on the same model. Your table has a 'parent_id' column. Simple example will be categories, then you do not have to create a 'sub_categories' table and can just add a 'parent_id' column.
Generate a unique slug. It will suffix "-index" if slug is already in use
Create a list of models. This will create a unique slug from all those models.
Lets assume you have an images table and images_tab table. Then you can 'tag,link' image to a model, instead of reuploading the same image, so you can tag 1 image to multiple models, For example you have a 'gallery' and you can tag those images to a news article, or to a player or to a banner, etc.
For news, blogs websites. Example: You have a sport news website. You can then tag news articles to a player, team, venue. So when you visit the players page, you can easily find all his tagged news articles.
Generate a complete url from yourself and category_id slug. Example: Your categories have the 'parent_id' and you want to generate the complete url. Then you can find the category, entry on the full url and do not need to explode on the slugs and find it.
Generate a complete url from yourself and parent's slug. Example: Your categories have the 'parent_id' and you want to generate the complete url. Then you can find the category, entry on the full url and do not need to explode on the slugs and find it.
composer require bpocallaghan/titan
- Documentation (50%)
- Cleanup code
- Rename, more descriptive names for the classes
Please keep in mind this is for my personal workflow and might not fit your need. I developed this to help speed up my day to day workflow. Please let me know about any issues or if you have any suggestions.