multek/laravel-nps
Composer 安装命令:
composer require multek/laravel-nps
包简介
A simple, focused NPS (Net Promoter Score) package for Laravel applications.
README 文档
README
A simple, focused NPS (Net Promoter Score) package for Laravel applications. Collect user feedback on a 0-10 scale with survey campaigns, cooldown logic, and dismissal tracking.
Installation
composer require multek/laravel-nps
Publish the config and migrations:
php artisan vendor:publish --tag=nps-config php artisan vendor:publish --tag=nps-migrations php artisan migrate
Setup
Add the HasNpsResponses trait to your User model:
use Multek\Nps\Traits\HasNpsResponses; class User extends Authenticatable { use HasNpsResponses; }
Usage
Creating a Survey
use Multek\Nps\Models\NpsSurvey; $survey = NpsSurvey::create([ 'name' => 'Q1 2026', 'description' => 'Quarterly NPS survey', 'is_active' => true, ]);
Checking Eligibility
$user->canAnswerNps(); // checks cooldown, dismissals, eligibility $user->canAnswerNps($survey); // for a specific survey
Recording Responses
$response = $user->answerNps($survey, 9, 'Great service!', ['source' => 'web']);
Dismissals
$user->dismissNps($survey); // records dismissal with attempt tracking
Using the Facade
use Multek\Nps\Facades\Nps; Nps::currentSurvey(); // active survey or null Nps::forUser($user); // survey data if eligible, null otherwise Nps::respond($surveyId, 9); // record response for auth user Nps::score($survey); // NPS score (-100 to 100) Nps::stats($survey); // {score, total, promoters, passives, detractors}
Inertia Integration
Share NPS data via your HandleInertiaRequests middleware:
public function share(Request $request): array { return [ ...parent::share($request), 'nps' => fn () => \Multek\Nps\Facades\Nps::forUser($request->user()), ]; }
In your React component:
const { nps } = usePage().props; if (nps) { // Show NPS modal with nps.survey_id, nps.name, nps.description }
API Routes
Routes are disabled by default. Enable them in config/nps.php:
'routes_enabled' => true,
| Method | URI | Description |
|---|---|---|
| GET | /api/nps/current |
Get active survey for auth user |
| POST | /api/nps/{survey}/respond |
Submit response |
| POST | /api/nps/{survey}/dismiss |
Record dismissal |
Events
| Event | When |
|---|---|
NpsResponseSubmitted |
User submits a response |
NpsSurveyDismissed |
User dismisses the NPS prompt |
NpsSurveyCompleted |
Survey reaches end date (dispatch manually) |
use Multek\Nps\Events\NpsResponseSubmitted; Event::listen(NpsResponseSubmitted::class, function ($event) { if ($event->response->is_detractor) { // Alert customer success team } });
Configuration
See config/nps.php for all options including:
cooldown_days— days between surveys (default: 90)max_attempts— max times to show after dismissals (default: 3)attempt_intervals— days between re-shows (default: [3, 7])eligibility_check— custom closure for additional eligibility logic
License
MIT
multek/laravel-nps 适用场景与选型建议
multek/laravel-nps 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「survey」 「laravel」 「feedback」 「NPS」 「net-promoter-score」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 multek/laravel-nps 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 multek/laravel-nps 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 multek/laravel-nps 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel wrapper for surveyjs library
Symfony2 Bundle for Bootstrap MaxLength.js - An visual feedback indicator for the MaxLength attribute
TYPO3 Feedback Extension - The TYPO3 Feedback Extension is a great tool for gathering feedback from visitors or customers on your website. With the All In One TYPO3 Feedback extension, website admin can easily add feedback forms in various styles to their website, allowing them to collect valuable i
Package for create surveys in laravel
Optical Mark Recognition from PHP
With feedback.js plugin repository and html2canvas with layout Bootstrap 3
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-01