Install Dependencies:
composer require matt-daneshvar/laravel-survey:"dev-translatable" tapp/filament-survey:"^3.0"
Add the custom repository to composer.json as per the README.
Run Migrations:
php artisan vendor:publish --provider="MattDaneshvar\Survey\SurveyServiceProvider" --tag="migrations"
php artisan migrate
Register Plugin:
Add to app/Providers/Filament/AdminPanelProvider.php:
public function panel(Panel $panel): Panel {
return $panel
->plugins([
FilamentSurveyPlugin::make(),
SpatieLaravelTranslatablePlugin::make(),
]);
}
First Survey Creation:
php artisan vendor:publish --tag="filament-survey-config") to enable Sections/Questions resources if needed.Create a Survey:
en, es) if using translations.Add Sections:
Add Questions:
true.Publish and Test:
Filament Resources:
/resources/surveys – Manage surveys./resources/entries – View/analyze responses (answers consolidated here)./resources/questions, /resources/sections – If published via config.Config File:
php artisan vendor:publish --tag="filament-survey-config"
enable_question_resource and enable_section_resource to control visibility.Translations:
php artisan vendor:publish --tag="filament-survey-translations"
// Example: Customizing the relation manager (via config)
'survey_relation_managers' => [
'sections' => [
'label' => 'Sections',
'relation' => 'sections',
'subrelation' => 'questions',
],
],
spatie/eloquent-sortable for reordering sections/questions via Filament’s sortable widgets.maatwebsite/excel).// Example: Customizing the Entries table columns
EntriesResource::modifyTableColumns(function (Table $table) {
$table
->columns([
Tables\Columns\TextColumn::make('survey.title'),
Tables\Columns\TextColumn::make('created_at')->dateTime(),
// Custom column for answer data
Tables\Columns\TextColumn::make('answers_data')->json(),
]);
});
SpatieLaravelTranslatablePlugin to manage translations for:
// Example: Adding a translatable field to a question
use Filament\Forms\Components\SpatieTranslatableFields;
TextInput::make('title')
->translatable()
->required(),
import and export actions for surveys/entries.
// Example: Adding an export button to the Surveys table
SurveysResource::modifyTableBulkActions(function (Table $table) {
$table->action(ExportAction::make());
});
laravel-survey-frontend to render forms.{!! Survey::find($surveyId)->renderForm() !!}
rating type) by publishing the package’s views and overriding templates.TextInput::make('question_text')
->rules(['required', 'max:255'])
->columnSpanFull(),
filament/spatie-laravel-charts to visualize response data:
use Filament\Charts\Chart;
Chart::make()
->title('Survey Responses Over Time')
->dataset('responses', [
'data' => Entry::query()
->selectRaw('DATE(created_at) as date, COUNT(*) as count')
->groupBy('date')
->get(),
]),
SurveysResource::configurePolicies([
'viewAny' => [SurveyPolicy::class, 'viewAny'],
]);
public function viewAny(User $user) {
return $user->hasRole(['admin', 'survey_manager']);
}
// In EventServiceProvider
protected $listen = [
'MattDaneshvar\Survey\Events\SurveySubmitted' => [
SurveySubmittedHandler::class,
],
];
notify() helper or a queue job.Schema Conflicts:
surveys, questions, or responses tables, migrations may fail. Run:
php artisan schema:dump
to compare schemas before migrating.Translatable Fields Require Setup:
dev-translatable fork of Laravel Survey adds translatable fields, but Filament’s translatable plugin must be installed (spatie/laravel-translatable). Missing this will cause errors when saving translated content.Relation Manager Caching:
// In config/filament-survey.php
'relation_manager_options' => [
'sections' => [
'loadRecords' => function () {
return Section::query()->where('survey_id', $this->record->id)->orderBy('sort_order');
},
],
],
Excel Export Limitations:
maatwebsite/excel dependency may conflict with other packages using the same namespace. Use:
composer require maatwebsite/excel:^3.1
to pin a specific version.Sortable Fields Dependencies:
spatie/eloquent-sortable must be installed and migrations run for drag-and-drop to work. Check:
php artisan vendor:publish --provider="Spatie\Sortable\SortableServiceProvider" --tag="sortable-migrations"
php artisan migrate
Relation Manager Not Loading:
php artisan filament:cache-clear
surveys table (e.g., hasMany for sections).**Translations Not S
How can I help you explore Laravel packages today?