Download the PHP package detosphere-ltd/laravel-faqs without Composer
On this page you can find all versions of the php package detosphere-ltd/laravel-faqs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download detosphere-ltd/laravel-faqs
More information about detosphere-ltd/laravel-faqs
Files in detosphere-ltd/laravel-faqs
Package laravel-faqs
Short Description Frequently asked questions crud implementation
License MIT
Informations about the package laravel-faqs
Laravel FAQs
This is a simple package to help manage frequently asked questions in a project.
Installation
You can install the package via composer by running:
After the installation has completed, the package will automatically register itself. Run the following to publish the migration file
After publishing the migration you can create the faqs table by running the migrations:
Models and Migrations
This package has only one model (Faq
) and its corresponding migration file. You are allowed to extend it and use it any how you want. The model only guarded properties on the model are the id
and uuid
.
Scopes
The Faq model has scopeType
to query faqs by type. It is as easy as shown below.
Action classes
This package exposes four action classes. Find details about them below.
CreateFAQAction
This is used to create a new faq. The execute method accepts an array. It returns the created faq.
UpdateFAQAction
This is used to update an already existing faq. The execute method accepts the faq to update and an array. It returns the updated faq.
DeleteFAQAction
This is used to delete an existing faq from the database. The execute method accepts the faq to delete. Faqs are soft deleted. It returns void.
IncrementFAQHelpfulnessAction
This is used to increment the helpful_yes
and helpful_no
of an existing faq in the database. The execute method accepts the faq to increment and the helpfulness to increment. Helpful must be yes
or no
. It returns the incremented faq. Throws an query exception if invalid helpful
paramater is passed.
Usage
You can instantiate the class like you would any normal PHP class
Also, you can also resolve the class from laravel's container
Lastly, you can also inject the action class into your controller method like below.
Testing
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-faqs with dependencies
alhaji-aki/laravel-uuid Version ^1.0
illuminate/database Version ^7.30|^8.0
illuminate/support Version ^7.30|^8.0