wi3edigital/laravel-simple-forms (0.0.2)
Installation
{
"repositories": [{
"type": "composer",
"url": " "
}
]
}composer require wi3edigital/laravel-simple-forms:0.0.2About this package
Laravel Simple Forms
Contact and feedback forms for Laravel applications built on Livewire and Flux UI.
Requirements
- PHP 8.4+
- Laravel 12
- Livewire 4
- Flux UI 2
Installation
composer require wi3edigital/laravel-simple-forms
Publish and run the migrations:
php artisan vendor:publish --tag=simple-forms-migrations
php artisan migrate
Configuration
Publish the config file:
php artisan vendor:publish --tag=simple-forms-config
// config/simple-forms.php
return [
// Blade layout wrapping the Livewire components
'layout' => 'layouts.guest',
'feedback' => [
// Map context strings to callout text shown above the feedback form.
// Use :app as a placeholder for the application name.
'contexts' => [
'first_week' => 'You\'ve been using :app for about a week.',
'inactivity_notice' => 'We noticed you haven\'t signed in for a while.',
],
// Context strings that show the additional context rating slider.
'context_ratings' => ['first_week', 'six_months'],
// Per-context slider labels: [label, left, center, right]
'context_rating_labels' => [
'first_week' => [
'How well does :app meet your expectations?',
'Much worse than expected',
'',
'Much better than expected',
],
],
],
];
Usage
Contact request form
Drop the Livewire component into any Blade view:
<livewire:simple-forms::contact-request />
The form collects subject, body, email, and an optional send me a copy checkbox. It is rate-limited to 2 submissions per 20 seconds per IP.
Feedback form
{{-- Basic --}}
<livewire:simple-forms::user-feedback-form />
{{-- With context (shows custom callout text from config) --}}
<livewire:simple-forms::user-feedback-form context="first_week" />
{{-- Pass the authenticated user explicitly (falls back to Auth::id()) --}}
<livewire:simple-forms::user-feedback-form :user-id="$user->id" context="inactivity_notice" />
Context can also be passed as a query string parameter: ?context=first_week.
The form collects a satisfaction rating (1–5) and a free-text message. When the context is listed in feedback.context_ratings, an additional context-specific rating slider appears.
Listening to events
use Wi3eDigital\SimpleForms\Events\ContactRequestSubmitted;
use Wi3eDigital\SimpleForms\Events\ContactRequestRateLimited;
use Wi3eDigital\SimpleForms\Events\FeedbackSubmitted;
// Send a notification when a contact request arrives
Event::listen(ContactRequestSubmitted::class, function (ContactRequestSubmitted $event) {
Notification::route('mail', config('mail.admin_address'))
->notify(new NewContactRequestNotification($event->contactRequest));
});
// Log rate limit hits
Event::listen(ContactRequestRateLimited::class, function (ContactRequestRateLimited $event) {
Log::warning("Contact form rate limited. Retry in {$event->secondsUntilAvailable}s.");
});
// Store feedback analytics
Event::listen(FeedbackSubmitted::class, function (FeedbackSubmitted $event) {
Analytics::track('feedback_submitted', [
'satisfaction' => $event->feedback->satisfaction,
'context' => $event->feedback->context,
]);
});
Filament panel integration
Register the plugin in your Filament panel provider:
use Wi3eDigital\SimpleForms\Filament\SimpleFormsPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
SimpleFormsPlugin::make(),
]);
}
This adds Contact Requests and User Feedback resource pages to your panel.
Customising views
Publish the Blade views to override them:
php artisan vendor:publish --tag=simple-forms-views
Views land in resources/views/vendor/simple-forms/livewire/.
Translations
Publish the language files:
php artisan vendor:publish --tag=simple-forms-lang
Files land in lang/vendor/simple-forms/.
Models
| Model | Table | Key columns |
|---|---|---|
ContactRequest |
contact_requests |
subject, body, email, user_id, copy, status |
UserFeedback |
user_feedbacks |
context, message, satisfaction, context_rating, user_id |
Both models have a user() BelongsTo relation using the model configured in auth.providers.users.model.
ContactRequest has a status column cast to ContactRequestStatusEnum.
License
MIT
Dependencies
Dependencies
| ID | Version |
|---|---|
| danharrin/livewire-rate-limiting | ^1.0 || ^2.0 |
| illuminate/contracts | ^12.0 |
| illuminate/support | ^12.0 |
| livewire/flux | ^2.14 |
| livewire/flux-pro | ^2.14 |
| livewire/livewire | ^4.0 |
| php | ^8.4 |
Development dependencies
| ID | Version |
|---|---|
| filament/filament | ^5.0 |
| larastan/larastan | ^3.9 |
| laravel/pint | ^1.29 |
| orchestra/testbench | ^10.0 |
| pestphp/pest | ^4.0 |
| pestphp/pest-plugin-laravel | ^4.0 |