bensondevs/laravel-faq

A simple, flexible, and customizable FAQ management package for Laravel.

v1.0.0-beta.1 2025-06-13 10:48 UTC

This package is auto-updated.

Last update: 2025-06-13 10:55:39 UTC


README

A simple, flexible, and customizable FAQ management package for Laravel.
Built with tagging, sorting, and localization in mind.

Developed by Bensondevs

๐Ÿš€ Features

  • Add FAQs with or without tags
  • Tag-based filtering
  • Multi-lingual question & answer support (via spatie/laravel-translatable)
  • Sortable (via spatie/eloquent-sortable)
  • API-ready with Resources
  • Easy integration into existing Laravel apps
  • Workbench support for local testing

๐Ÿ“ฆ Installation

Require the package via Composer:

composer require bensondevs/laravel-faq

Publish config & migrations:

# Publish config file
php artisan vendor:publish --tag=faq-config

# Publish migrations file
php artisan vendor:publish --tag=faq-migrations

โš™๏ธ Configuration

The default config file config/faq.php will be published. You can customize table names and other options there.

โœ… Usage

Add a FAQ (no tag):

use Bensondevs\LaravelFaq\Faq;

$faq = Faq::add('What is Laravel?', 'Laravel is a PHP framework.');

Add a FAQ with a tag:

$faq = Faq::add(
    question: 'What is PHP?', 
    answer: 'A scripting language.', 
    locale: 'en', 
    tag: 'php',
);

Add with multiple tags:

$faq = Faq::add(
    question: 'What is Tailwind?', 
    answer: 'A CSS framework.', 
    locale: 'en', 
    tag: ['css', 'tailwind'],
);

Retrieve all FAQs:

Faq::all(); // returns FaqResource::collection

Retrieve by tag key or instance:

use Bensondevs\LaravelFaq\Models\Tag;

Faq::all('php');
Faq::all(Tag::first());
Faq::all(['php', 'laravel']);

๐Ÿงช Testing

This package uses Orchestra Testbench.

Run all tests:

./vendor/bin/phpunit

๐ŸŽจ Code Style

This package uses Laravel Pint for formatting.

To auto-format your code:

./vendor/bin/pint

๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license.

๐Ÿ™Œ Credits