codewithren/contactform

Laravel contact form package

Installs: 9

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

Language:Blade

Type:package

v1.0.0 2025-06-07 18:22 UTC

This package is not auto-updated.

Last update: 2025-06-09 15:43:33 UTC


README

A simple, reusable contact form package for Laravel using Livewire v3. Perfect for quickly adding a styled contact form to your Laravel projects.

๐Ÿ“ฌ Laravel Livewire Contact Form

๐Ÿš€ Features

๐Ÿงฉ Plug-and-play Livewire component

๐ŸŽจ Beautiful Tailwind CSS design

๐Ÿ“ง Email sending support

๐Ÿ”’ Validation and CSRF protection

โšก Uses Laravel component structure (no config needed)

๐Ÿ“ฆ Installation

composer require codewithren/contactform:dev-main --with-all-dependencies

๐Ÿง  Requirements

PHP 8.2+

Laravel 10/11/12

Livewire 3+

Sweetalert2

Install Sweetalert through composer and run our installer.

composer require wavey/sweetalert && php artisan sweetalert:install

Include the Sweetalert2 javascript and then include our sweetalert 2 layout component.

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
@include('sweetalert::sweetalert')

Include the scripts in your layout

<script>
    window.addEventListener('alert', (event) => {
        var data = event.detail;
        console.log(data);
        Swal.fire({
            title: "Success",
            text: data.message,
            icon: "success",
            toast: true,
            position: "top-end",
            showCloseButton: true,
            showConfirmButton: false,
            timer: 3000,
            timerProgressBar: true,
            customClass: {
                popup: 'rounded-xl shadow-md text-sm bg-white',
                title: 'font-semibold text-gray-800',
                closeButton: 'text-gray-500 hover:text-red-500',
            },
            didOpen: (toast) => {
                toast.addEventListener('mouseenter', Swal.stopTimer)
                toast.addEventListener('mouseleave', Swal.resumeTimer)
            }
        });
    });
    window.addEventListener('alert-error', (event) => {
        var data = event.detail;
        console.log(data);
        Swal.fire({
            title: "Error",
            text: data.message,
            icon: "error",
            toast: true,
            position: "top-end",
            showCloseButton: true,
            showConfirmButton: false,
            timer: 3000,
            timerProgressBar: true,
            customClass: {
                popup: 'rounded-xl shadow-md text-sm bg-white',
                title: 'font-semibold text-gray-800',
                closeButton: 'text-gray-500 hover:text-red-500',
            },
            didOpen: (toast) => {
                toast.addEventListener('mouseenter', Swal.stopTimer)
                toast.addEventListener('mouseleave', Swal.resumeTimer)
            }
        });
    });
</script>

To enable email notifications, configure your Mailable in the package or override the email logic using events or extending the component. ๐Ÿงพ Publish Config required

php artisan vendor:publish --tag=contactform-config

In .env file add ADMIN_EMAIL and make sure to configure your stmp

ADMIN_EMAIL="admin@gmail.com"

๐Ÿ›  Usage

Include the Livewire component in your Blade file:

<livewire:contact-form />

๐Ÿ—ƒ๏ธ Migrations

The package automatically loads its own migrations.

To run them:

php artisan migrate
php artisan queue:work

That's it! ๐ŸŽ‰ The form includes fields for name, email, and message. ๐Ÿ“จ Email Support

To publish the resources views and livewire component file (optional).

php artisan vendor:publish --tag=contactform-views
php artisan vendor:publish --tag=contactform-livewire

The views will be published to:

resources/views/vendor/contactform/

โœ… Validation Rules

The component validates the following:

name: required, string

email: required, valid email

message: required, min:10

You can customize these by publishing and editing the component. ๐Ÿงช Example Form Output

๐Ÿ™‹โ€โ™‚๏ธ Maintainer

Renish Siwakoti GitHub: @Renish437 ๐Ÿ“„ License

This package is open-sourced under the MIT license.