Download the PHP package artflow-studio/snippets without Composer
On this page you can find all versions of the php package artflow-studio/snippets. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download artflow-studio/snippets
More information about artflow-studio/snippets
Files in artflow-studio/snippets
Package snippets
Short Description A Laravel package for performing basic operations.
License MIT
Informations about the package snippets
🚀 AF Web Snippets
A powerful collection of Laravel web snippets to supercharge your development workflow
    📋 Table of Contents
- ✨ Features
- 🔧 Installation
- 🚀 Quick Start
- 📚 Components
- AFdropdown - Advanced Searchable Dropdown
- Dynamic Dropdown
- Unique ID Generator
- Data Formatters
- � AFdropdown Quick Guide
- 📖 Detailed Documentation
- 🔍 Examples
- 📄 License
✨ Features
⭐ NEW - AFdropdown Component
- 🔍 Multiple Search Modes - basic, contains, advanced, exact
- 📊 Multi-Column Search - Search across multiple fields
- ⌨️ Keyboard Navigation - Arrow keys, Enter, Escape
- 💾 Result Caching - Redis/Cache support for performance
- 🎨 Custom Formatters - Format results your way
- � Custom Callbacks - Modify queries dynamically
- ⚡ Livewire 3.6+ - Modern event dispatch & attributes
- ♿ Accessibility - Full ARIA support
- 📱 Responsive - Bootstrap 5 compatible
Core Features
- 🎯 Advanced Dropdowns - Livewire-powered searchable dropdowns
- 🆔 Unique ID Generator - Multiple ID generation strategies
- 📱 Data Formatters - Format phone numbers and CNIC
- 📱 Responsive Design - Bootstrap-compatible components
- ⚡ Performance Optimized - Efficient queries with debouncing
- 🛠️ Highly Customizable - Extensive configuration options
- 🔒 Secure - Built-in validation and error handling
🔧 Installation
Install the package via Composer:
Publish package assets (optional):
🚀 Quick Start
AFdropdown (NEW)
Handle selection:
📚 Components
AFdropdown - Advanced Searchable Dropdown ⭐ MAIN
Modern Livewire 3.6+ component with enterprise-grade features
Key Features
✅ Real-time filtering with debouncing
✅ 4 search modes (basic, contains, advanced, exact)
✅ Multi-column searching
✅ Result caching for performance
✅ Keyboard navigation support
✅ Custom formatters & queries
✅ Full accessibility (ARIA)
✅ Comprehensive error handling
Basic Usage
Advanced Usage
Search Modes
| Mode | Description | Example |
|---|---|---|
basic |
Single column LIKE search | john → finds "john", "johnny" |
contains |
Multi-column OR search | john → searches all columns |
advanced |
Word-by-word matching | john doe → both words needed |
exact |
Exact match only | [email protected] → exact match |
Event Handling
Keyboard Navigation
| Key | Action |
|---|---|
| ↓ | Next result |
| ↑ | Previous result |
| ↩ | Select highlighted |
| Esc | Close dropdown |
📖 Full Documentation
Complete guides with detailed examples:
- 📄 AFdropdown-GUIDE.md - Complete reference guide (300+ lines)
- 📄 EXAMPLES.md - 8+ real-world examples
Dynamic Dropdown (Legacy)
Basic searchable dropdown component. For new projects, use AFdropdown instead.
Unique ID Generator
Generate unique identifiers for your models:
Data Formatters
Format phone numbers and CNIC:
🎯 AFdropdown Quick Guide
Installation & Setup
-
Component loads in Livewire:
-
Add to your Livewire component:
- Use in blade:
Common Configurations
Basic Customer Search:
Multi-Field Search:
With Caching:
Custom Format:
Performance Tips
- ✅ Use
minSearchLengthto reduce queries (set to 2) - ✅ Enable
enableCachefor static data - ✅ Use
queryCallbackto filter early - ✅ Add database indexes on search columns
- ✅ Reduce
resultLimitif not needed
📖 Detailed Documentation
AFdropdown Complete Guides
AFdropdown-GUIDE.md - 300+ Lines
Comprehensive reference covering:
- All configuration options
- All 4 search modes with examples
- Caching strategies
- Event handling
- Keyboard navigation
- 5+ real-world examples
- Complete troubleshooting guide
- Performance optimization
- Best practices
EXAMPLES.md - Copy-Paste Ready
Production-ready examples:
- Basic customer selection
- Product search with stock
- User selection in admin
- Location search (multi-term)
- Invoice line items
- Category selection
- Dependent dropdowns
- Error handling patterns
🔍 Examples
Example 1: Basic Customer Selection
Example 2: Multi-Column Product Search
Example 3: Advanced Location Search
📋 Troubleshooting
No Results Showing?
- Check
minSearchLengthsetting - Verify model and column names exist
- Test query in Tinker:
php artisan tinker - Check that model has data
Slow Performance?
- Enable caching:
'enableCache' => true - Add database indexes
- Use
queryCallbackto filter early - Reduce
resultLimit
Keyboard Navigation Not Working?
- Click input to focus first
- Check browser console (F12) for errors
- Verify Alpine.js is loaded
- Try in different browser
📄 License
MIT License - See LICENSE file for details
👥 Contributors
Built with ❤️ for the Laravel & Livewire community
📞 Support
For issues and questions:
- Check AFdropdown-GUIDE.md for detailed documentation
- Review EXAMPLES.md for code samples
- See troubleshooting sections
- Check error logs
Latest Version: 2.0.0
Livewire: 3.6+
Laravel: 12+
PHP: 8.2+
Service Provider Registration
The package uses Laravel's auto-discovery feature. If you're using Laravel 5.5+, the service provider will be automatically registered.
Publish Assets (Optional)
🚀 Quick Start
Add the following line at the end of your <body> tag in your Blade layout:
That's it! You're ready to use AF Web Snippets in your Laravel application.
📚 Components
🎯 Dynamic Dropdown (AFDropdown)
A powerful Livewire component for searchable dropdowns with real-time filtering, minimum search length, and elegant UI.
Basic Usage
Advanced Configuration
AFDropdown Event System
AFDropdown is a fully event-driven component. When a user selects an item, it dispatches events that parent components can listen to and react upon.
Event Flow Diagram
Event Data Structure
When AFDropdown emits the afdropdown-selected event, it sends the following data:
Listening to Events with #[On] Attribute (Recommended)
Listening to Multiple Dropdowns
Use the model class to differentiate between different dropdown selections:
Listening for Clear Events
AFDropdown also emits a afdropdown-cleared event when the user clears the search:
Listening to Selection Events in Livewire Components
The AFDropdown component emits the afdropdown-selected event when a user selects an item. Parent Livewire components can listen to this event:
Or using the traditional getListeners() method:
Using AFDropdown in Blade Templates
Use the @livewire directive to mount the component:
AFDropdown Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
model |
string | required | Full namespace to Eloquent model class |
column |
string | required | Database column to search and display |
classes |
string | 'form-control' | CSS classes for input styling |
placeholder |
string | 'Search...' | Input placeholder text |
minSearchLength |
int | 3 | Minimum characters before showing results |
resultLimit |
int | 8 | Maximum number of results to display |
displayFormat |
string | 'label' | Format for displaying results |
additionalColumns |
array | [] | Additional columns to show in results |
Advanced: Custom Search Filtering
To customize the search query (e.g., filter by branch, status, etc.), extend the component:
Then register it in your service provider:
Example: Customer Selection in Invoices
🔍 Distinct Select (AFDistinctSelect)
A specialized component for preventing spelling mistakes by showing existing values from the database. Perfect for fields like cities, countries, or categories where you want consistent data entry.
Basic Usage
Advanced Configuration
Handling Updates in Parent Component
AFDistinctSelect Features
- ✅ Spelling Prevention - Shows existing values to prevent duplicates
- ✅ Type-ahead Search - Real-time filtering of existing values
- ✅ Exact Value Selection - Updates input with exact database spelling
- ✅ Data Consistency - Ensures uniform data entry
- ✅ Bootstrap Compatible - Seamless integration with Bootstrap styling
- ✅ Customizable - Flexible configuration options
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
model |
string | required | Eloquent model class |
column |
string | required | Database column to search and display |
value |
string | '' | Current field value |
wireModel |
string | column name | Livewire property to bind |
classes |
string | 'form-control' | CSS classes for input |
placeholder |
string | 'Select or type...' | Input placeholder text |
minSearchLength |
int | 1 | Minimum characters before search |
maxResults |
int | 10 | Maximum results to show |
AFDropdown Features
- ✅ Real-time Search - Debounced search with 300ms delay
- ✅ Minimum Search Length - Configurable minimum characters (default: 3)
- ✅ Loading States - Visual feedback during search
- ✅ Clear Button - Easy reset functionality
- ✅ Keyboard Navigation - Accessible dropdown interaction
- ✅ Bootstrap Compatible - Seamless integration with Bootstrap styling
AFDropdown Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
model |
string | required | Eloquent model class |
column |
string | required | Database column to search and display |
classes |
string | 'form-control' | CSS classes for input |
placeholder |
string | 'Search...' | Input placeholder text |
min-search-length |
int | 3 | Minimum characters before search |
🆔 Unique ID Generator
Generate unique identifiers for your models with multiple strategies and collision detection.
Basic Usage
Advanced Usage
ID Generation Methods
unique6digitID()- Generates 6-digit numeric IDs (100000-999999)generateUniqueBase36ID()- Generates Base36 IDs with timestamp encodinggenerateUniqueID($model, $column)- Generates unique IDs with collision checking
📱 Data Formatters
Format common data types for Pakistani users with intelligent detection and formatting.
Pakistani Phone Number Formatter
Pakistani CNIC Formatter
Usage in Models
🎨 Customization
Styling AFDropdown
🔍 Examples
Dropdown with Event Handling
🛠️ Requirements
- PHP >= 8.0
- Laravel >= 9.0
- Livewire >= 3.0
- Bootstrap >= 5.0 (for styling)
🤝 Contributing
We welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👥 Authors
- @RaHee554 - Initial work and maintenance
🙏 Acknowledgments
- Laravel community for the amazing framework
- Livewire team for the reactive components
- Bootstrap team for the UI framework
- All contributors who help improve this package
Made with ❤️ for the Laravel community