noxoua/filament-coupons
Composer 安装命令:
composer require noxoua/filament-coupons
包简介
A flexible coupon management system for Filament
README 文档
README
Filament Coupons
A flexible coupon management system for Filament 3.x with customizable strategies and usage tracking.
Installation
composer require noxoua/filament-coupons php artisan filament-coupons:install
Setup
Add the plugin to your Filament panel:
use Noxo\FilamentCoupons\CouponsPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ CouponsPlugin::make(), ]); }
Usage
Creating Strategies
Create custom coupon strategies:
php artisan make:coupons-strategy FreeSubscription
Register in config:
// config/filament-coupons.php 'strategies' => [ \App\Coupons\FreeSubscriptionStrategy::class, ],
Strategy Example
class FreeSubscriptionStrategy extends CouponStrategy { public function schema(): array { return [ Forms\Components\TextInput::make('days') ->label('Days') ->numeric() ->required(), ]; } public function apply(Coupon $coupon): bool { $user = auth()->user(); $days = $coupon->payload['days'] ?? 7; // Your business logic $user->extendSubscription($days); // Configure notifications and redirects $this->successNotification( fn ($notification) => $notification ->title('Coupon Applied!') ->body("You got {$days} free days") ); $this->successRedirectUrl('/dashboard'); // Consume coupon return coupons()->consume($coupon, couponable: $user); } }
Available methods for strategies:
- Custom notifications
successNotificationfailureNotification
- Custom redirects
successRedirectUrlfailureRedirectUrl
Using the Action
The package provides a ready-to-use ApplyCouponAction that can be integrated anywhere in your Filament application:
In Livewire Components:
use Noxo\FilamentCoupons\Actions\ApplyCouponAction; class Dashboard extends Component implements HasActions { use InteractsWithActions; public function applyCouponAction(): Action { return ApplyCouponAction::make() ->button() ->label('Apply Coupon'); } public function render() { return view('dashboard'); } }
{{-- dashboard.blade.php --}} <div> <h2>Dashboard</h2> {{ $this->applyCouponAction }} </div>
In Resource Pages:
use Noxo\FilamentCoupons\Actions\ApplyCouponAction; class ListPosts extends ListRecords { protected function getHeaderActions(): array { return [ Actions\CreateAction::make(), ApplyCouponAction::make(), ]; } }
In Custom Pages:
use Noxo\FilamentCoupons\Actions\ApplyCouponAction; class SettingsPage extends Page { protected function getHeaderActions(): array { return [ ApplyCouponAction::make() ->label('Redeem Coupon') ->color('success'), ]; } }
Manual Using
$coupon = Coupon::where('code', 'WELCOME2012')->first(); // Validate if (coupons()->isValid($coupon)) { // Apply coupons()->applyCoupon($coupon); }
Testing
Run the test suite using:
composer test
The tests verify all aspects of coupon functionality, including strategy handling and integration with Filament. We recommend running tests after any changes.
Credits
License
The MIT License (MIT). Please see License File for more information.
noxoua/filament-coupons 适用场景与选型建议
noxoua/filament-coupons 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 116 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「coupons」 「filament」 「filament-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 noxoua/filament-coupons 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 noxoua/filament-coupons 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 noxoua/filament-coupons 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
iOS Passbook for Symfony
Adds Discount and Coupon support for SilverShop.
Billing package for Laravel 5.5 supporting packages, plans, coupons, addons, payments and subscriptions
Extend the checkout experience with coupons and discount codes.
Adds Discount and Coupon support for SilverShop.
Laravel 10+ compatible promotion codes generator and validator.
统计信息
- 总下载量: 116
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-03
