## Getting Started
### Minimal Setup
1. **Install the Package**
```bash
composer require tapp/filament-survey
Ensure compatibility with Filament 3.2+ and Laravel 12. Required dependencies (matt-daneshvar/laravel-survey, maatwebsite/excel, spatie/eloquent-sortable) must also be installed.
Publish Config & Migrations
php artisan vendor:publish --provider="Tapp\FilamentSurvey\FilamentSurveyServiceProvider"
php artisan migrate
Note: Laravel 12 users may need to adjust config/database.php for migration table naming conventions.
Register the Plugin
Update app/Providers/Filament/AdminPanelProvider.php for Filament 3.2+:
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
\Tapp\FilamentSurvey\FilamentSurveyPlugin::make(),
])
->discoverResources(
in_array($this->app->environment('local'), true),
app_path('Filament/Survey/')
);
}
First Use Case: Create a Survey
spatie/eloquent-sortable).Survey Creation & Management
created_at range).translatable trait optimizations.Question Types & Logic
SurveyQuestionResource::macro('customField', function (callable $callback) {
return $callback($this);
});
Response Handling
spatie/laravel-excel v3.x:
use Tapp\FilamentSurvey\Exports\SurveyResponseExport;
SurveyResponseExport::make()
->withHeadings(['Question', 'Response', 'Submitted At'])
->chunk(1000); // Leverage Laravel 12’s chunked exports
Integration with Filament 3.2
use Tapp\FilamentSurvey\Widgets\SurveyWidget;
SurveyWidget::make()
->survey($survey)
->submitButtonText('Submit Feedback')
->livewire(); // Explicitly use Filament 3.2’s Livewire components
SurveyWidget::make()
->survey(fn () => Survey::where('is_active', true)->first())
->canSeeSurvey(fn (User $user) => $user->can('view_active_surveys'));
Localization
lang:load for dynamic survey translations:
Survey::find($id)->loadTranslations(['title', 'description']);
{
"surveys.attributes.title": {
"en": "Customer Satisfaction",
"es": "Satisfacción del Cliente"
}
}
Custom Question Types (Filament 3.2) Register custom question types using Filament’s resource registration:
// app/Providers/FilamentSurveyServiceProvider.php
public function boot()
{
FilamentSurvey::registerQuestionType(
\App\Models\CustomQuestion::class,
\App\Filament\Resources\CustomQuestionResource::class,
alignment: 'end' // New Filament 3.2 alignment option
);
}
Webhook Triggers with Laravel 12 Use Laravel’s event dispatching with improved type safety:
use Tapp\FilamentSurvey\Events\SurveySubmitted;
SurveySubmitted::listen(function (SurveySubmitted $event) {
Notification::route('mail', $event->response->email)
->notify(new SurveySubmittedNotification($event->survey));
});
Bulk Actions (Filament 3.2)
Survey::enableSoftDeletes();
use Filament\Tables\Actions\BulkAction;
BulkAction::make('restore')
->action(function (Collection $records) {
foreach ($records as $record) {
$record->restore();
}
}),
Filament 3.2 Migration Issues
symfony/ux-live-component and filament/support are v1.0+.composer require filament/support:^1.0 filament/forms:^1.0
Laravel 12 Model Binding
Route::get('/surveys/{survey:model}', [SurveyController::class, 'show']);
Translatable Field Caching (Laravel 12)
Cache::tags() for translated survey fields:
Cache::tags(['survey-translations'])->put("survey:{$id}:translations", $translations);
php artisan cache:clear --tags=survey-translations
Excel Export Limits (Laravel 12)
spatie/laravel-excel config for large datasets:
'exports' => [
'chunk_size' => 2000, // Default: 1000 (Laravel 12 optimized)
],
Filament 3.2 Plugin Isolation
FilamentSurveyPlugin::make()
->disableResources(['Surveys', 'Questions'])
->registerResourcesManually();
Log Survey Events (Laravel 12) Use Laravel’s structured logging:
event(new SurveySubmitted($response))->log();
tail -f storage/logs/laravel.log | grep "survey:"
Validate Filament 3.2 Components
php artisan livewire:discover
Filament\Resources\Resource (v3.2).Database Seeding (Laravel 12) Use the updated seeder with Laravel 12’s database testing:
php artisan db:seed --class=FilamentSurveySeeder --force
.env:
DB_CONNECTION=testing
Customize Survey UI (Filament 3.2)
php artisan vendor:publish --tag="filament-survey-views"
resources/views/filament-survey/ for Filament 3.2’s new Blade directives (e.g., @filamentTables).Add Survey Metadata (Laravel 12)
Extend the Survey model with Laravel 12’s attributes:
// app/Models/Survey.php
use HasMany;
use Spatie\MediaLibrary\HasMedia;
protected $casts = [
'is_published' => 'boolean',
'publish_at' => 'datetime',
];
**API Endpoints (Laravel 12
How can I help you explore Laravel packages today?