cleaniquecoders/traitify
| Install | |
|---|---|
composer require cleaniquecoders/traitify |
|
| Latest Version: | 1.4.0 |
| PHP: | ^8.2|^8.3|^8.4 |
| Laravel: | 10 – 13 |
| License: | MIT |
| Last Updated: | Mar 30, 2026 |
| Links: | GitHub · Packagist |
Traitify
A Laravel package that streamlines development with reusable traits, contracts, and a powerful value generator system. Reduce boilerplate, standardize behavior, and enhance your models with automatic UUID, token, and slug generation.
✨ Features
- 🔧 11 Reusable Traits - UUID, Token, Slug, Meta, User, API, Search, and more
- 🎨 Customizable Generators - Flexible token, UUID, and slug generation
- ⚙️ Three-Tier Configuration - Model → Config → Default resolution
- 🔌 Extensible Architecture - Create custom generators easily
- 📦 Zero Configuration - Works out of the box with sensible defaults
- ✅ 100% Tested - Comprehensive test coverage with Pest PHP
📦 Installation
composer require cleaniquecoders/traitify
🚀 Quick Start
use CleaniqueCoders\Traitify\Concerns\InteractsWithUuid;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use InteractsWithUuid;
// UUID automatically generated on creation
}
$post = Post::create(['title' => 'Hello World']);
echo $post->uuid; // 9d9e8da7-78c3-4c9d-9f5e-5c8e4a2b1d3c
📚 Documentation
- Documentation Home - Complete documentation index
- Getting Started - Installation and setup
- Architecture - System design and patterns
- Traits Reference - All available traits
- Generators - Customizable value generation
- Configuration - Configuration options
- Examples - Real-world usage examples
- Advanced - Extend and customize
🔥 Popular Use Cases
Auto-Generate UUIDs
use InteractsWithUuid;
protected $uuid_column = 'id'; // Use UUID as primary key
Secure API Tokens
use InteractsWithToken;
protected $tokenGeneratorConfig = [
'length' => 64,
'prefix' => 'sk_',
'pool' => 'hex',
];
SEO-Friendly Slugs
use InteractsWithSlug;
protected $slugGeneratorConfig = [
'unique' => true,
'max_length' => 100,
];
🧪 Testing
composer test
📖 Available Traits
| Trait | Purpose |
|---|---|
InteractsWithUuid |
Auto-generate UUIDs |
InteractsWithToken |
Generate secure tokens |
InteractsWithSlug |
Create URL-friendly slugs |
InteractsWithMeta |
Manage JSON metadata |
InteractsWithUser |
Auto-assign user relationships |
InteractsWithApi |
API response formatting |
InteractsWithSearchable |
Full-text search |
InteractsWithDetails |
Eager load relationships |
InteractsWithEnum |
Enum helper methods |
InteractsWithResourceRoute |
Resource route generation |
InteractsWithSqlViewMigration |
SQL view migrations |
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING for details.
🔒 Security
If you discover any security issues, please review our security policy.
📝 Changelog
Please see CHANGELOG for recent changes.
👥 Credits
📄 License
The MIT License (MIT). Please see License File for more information.
Related Packages
Shrinkr is a Laravel package for shortening URLs, with custom slugs, analytics,...
Effortlessly manage your Laravel API versions with flexible, header-based versio...
Define, sign, dispatch and log outgoing webhooks in Laravel with retries, HMAC s...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.4.0 | ^8.2| | ^10.0|| | MIT | |
| 1.3.1 | ^8.2| | ^10.0|| | MIT | |
| 1.3.0 | ^8.2| | ^10.0|| | MIT | |
| 1.2.1 | ^8.2| | ^10.0|| | MIT | |
| 1.2.0 | ^8.2| | ^10.0|| | MIT | |
| 1.1.0 | ^8.2| | ^10.0|| | MIT | |
| v1.0.2 | ^8.2| | ^10.0|| | MIT | |
| v1.0.1 | ^8.2 | ^10.0|| | MIT | |
| v1.0.0 | ^8.2 | ^10.0|| | MIT |