PHP code example of denobraz / laravel-contact-form

1. Go to this page and download the library: Download denobraz/laravel-contact-form library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

denobraz / laravel-contact-form example snippets


Route::post('/contact-form', Denobraz\LaravelContactForm\Http\Controllers\ContactFormController::class);

'types' => [
        // `default` is the name of the contact form type
        'default' => [
            'data' => [
                // Here is rules for validation
                'name' => 'string|      // If you want to override the default message for some field
                // You can leave this array empty
                'name.rm is validated
                // You can leave this array empty (maybe just for record form data in the database)
                Denobraz\LaravelContactForm\Callbacks\DummyContactFormCallback::class,
            ]
        ],
        // `newsletter` is the name of the contact form type
        'newsletter' => [
            'data' => [
                'email' => 'string|

namespace App\ContactForm\Callbacks;

use App\Notifications\ManagerContactFormNotification;
use Denobraz\LaravelContactForm\Callbacks\ContactFormCallback;
use Illuminate\Support\Facades\Notification;

class SendManagerEmail extends ContactFormCallback
{
    // You must implement the `handle` method
    // where you can process the contact form data
    public function handle(): void
    {
        // You can access the contact form data using the following methods:
        $email = $this->contactForm->data('email');

        // To use the cookies, and meta-data, you need allow storing them in the config file.
        $fbpCookie = $this->contactForm->cookie('fbp');
        $ip = $this->contactForm->ip();
        $userAgent = $this->contactForm->userAgent();
        $referer = $this->contactForm->referer();
        $userId = $this->contactForm->userId();
        $someOtherMeta = $this->contactForm->meta('some_other_meta');
    
        // In the notification class we pass the contact form model with data
        $notification = new ManagerContactFormNotification($this->contactForm);
        Notification::route('mail', '[email protected]')->notify($notification);
    }
}
bash
php artisan vendor:publish --provider="Denobraz\LaravelContactForm\ContactFormServiceProvider" --tag="config"
bash
php artisan vendor:publish --provider="Denobraz\LaravelContactForm\ContactFormServiceProvider" --tag="migrations"
bash
php artisan migrate