detosphere-ltd/laravel-faqs
Composer 安装命令:
composer require detosphere-ltd/laravel-faqs
包简介
Frequently asked questions crud implementation
README 文档
README
This is a simple package to help manage frequently asked questions in a project.
Installation
You can install the package via composer by running:
composer require detosphere-ltd/laravel-faqs
After the installation has completed, the package will automatically register itself. Run the following to publish the migration file
php artisan vendor:publish --provider="DetosphereLtd\LaravelFaqs\FAQServiceProvider"
After publishing the migration you can create the faqs table by running the migrations:
php artisan migrate
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.
$faqs = \DetosphereLtd\LaravelFaqs\Models\Faq::type('type')->get();
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.
$faq = (new CreateFAQAction)->execute([ 'question' => 'What does your app do?', 'answer' => 'It helps manage Frequently asked questions on any application.', 'type' => 'type' ]);
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.
$faq = \DetosphereLtd\LaravelFaqs\Models\Faq::first(); $updatedFaq = (new UpdateFAQAction)->execute($faq, [ 'question' => 'What does your app do?', 'answer' => 'It helps manage Frequently asked questions on any application.', 'type' => 'type' ]);
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.
$faq = \DetosphereLtd\LaravelFaqs\Models\Faq::first(); (new DeleteFAQAction)->execute($faq);
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.
$faq = \DetosphereLtd\LaravelFaqs\Models\Faq::first(); $incrementedYes = (new IncrementFAQHelpfulnessAction)->execute($faq, 'yes'); $incrementedNo = (new IncrementFAQHelpfulnessAction)->execute($faq, 'no');
Usage
You can instantiate the class like you would any normal PHP class
(new CreateFAQAction)->execute([ 'question' => 'What does your app do?', 'answer' => 'It helps manage Frequently asked questions on any application.', 'type' => 'type' ]);
Also, you can also resolve the class from laravel's container
app(CreateFAQAction::class)->execute([ 'question' => 'What does your app do?', 'answer' => 'It helps manage Frequently asked questions on any application.', 'type' => 'type' ]);
Lastly, you can also inject the action class into your controller method like below.
<?php namespace App\Http\Controllers; use DetosphereLtd\LaravelFaqs\Actions\CreateFAQAction; class FaqController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function store(Request $request, CreateFAQAction $action) { $action->execute([ 'question' => $request->question, 'answer'=> $request->answer, 'type' => $request->type ]); return response(201); } }
Testing
vendor/bin/phpunit
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
detosphere-ltd/laravel-faqs 适用场景与选型建议
detosphere-ltd/laravel-faqs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「faqs」 「frequently-asked-questions」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 detosphere-ltd/laravel-faqs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 detosphere-ltd/laravel-faqs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 detosphere-ltd/laravel-faqs 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Faqs for NetCommons Plugin
Magento2 FAQ Extension Free
FAQs for Magento 2
adds FAQ page and FAQ Holder page to your Silverstripe application
A Laravel 4 package to add simple database driven FAQs to a site
Alfabank REST API integration
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-12