Releases: bensondevs/laravel-faq
Releases · bensondevs/laravel-faq
v1.0.0-beta.1 – First Beta Release
Laravel FAQ
A simple, flexible, and customizable FAQ management package for Laravel. Built with localization and tagging in mind.
✨ Features
- Add FAQs with multilingual support via
spatie/laravel-translatable
- Associate FAQs with tags (also translatable)
- Fetch FAQs filtered by:
- Tag instance
- Tag string key
- Tag ID
- Array of tags
- Sort FAQs using
spatie/eloquent-sortable
- Publishable config and migration files
- Easily extendable for admin panels or APIs
🚀 Installation
composer require bensondevs/laravel-faq
📦 Configuration
To publish the configuration file:
php artisan vendor:publish --tag=faq-config
You can then customize config/faq.php
.
🗃️ Migrations
To publish the migration files:
php artisan vendor:publish --tag=faq-migrations
Then run:
php artisan migrate
✅ Usage
Add an FAQ without tags
use Bensondevs\LaravelFaq\Faq;
$faq = Faq::add(
question: 'What is Laravel?',
answer: 'Laravel is a PHP framework.'
);
Add an FAQ with existing tag
use Bensondevs\LaravelFaq\Models\Tag;
$tag = Tag::create([
'key' => 'php',
'label' => ['en' => 'PHP'],
]);
$faq = Faq::add('What is PHP?', 'PHP is a language.', 'en', $tag);
Add an FAQ with new tags (strings)
$faq = Faq::add('What is Livewire?', 'A frontend package.', 'en', ['livewire', 'frontend']);
Fetch all FAQs
$faqs = Faq::all(); // returns a resource collection
Fetch FAQs by tag key
$faqs = Faq::all('frontend');
Fetch FAQs by tag instance or ID
$tag = Tag::find(1);
$faqs = Faq::all($tag);
$faqs = Faq::all(1);
🌐 Localization
Both question
and answer
fields support translations using Spatie's HasTranslations
. Example:
$faq->setTranslation('question', 'fr', 'Qu’est-ce que Laravel ?');
$faq->setTranslation('answer', 'fr', 'Laravel est un framework PHP.');
🧪 Testing
Run all tests:
./vendor/bin/phpunit
Run a specific test:
./vendor/bin/phpunit --filter it_can_fetch_faqs_by_tag_key
🧹 Code Style
To format with Laravel Pint:
./vendor/bin/pint
🧪 Workbench
This package includes a Laravel Workbench for local development. It supports:
- Local migration testing
- Local seeders
- Temporary SQLite DB creation
php artisan serve
from the workbench
To serve locally:
composer serve
🔖 Versioning
This package follows SemVer. The current release is:
v1.0.0-beta.1
📄 License
The MIT License (MIT). Please see License File for more information.
👤 Author
Simeon Bensona
bensondevs – bensondevs@gmail.com
🙏 Contributing
Feel free to submit PRs, issues, or feature requests. All contributions are welcome!