custom-d/cd-contact-form

Base Contact form package for laravel installs

v1.2.3 2023-06-27 03:53 UTC

This package is auto-updated.

Last update: 2024-06-13 13:18:04 UTC


README

installation

composer require custom-d/cd-contact-form

run php artisan cdcontactform:install to install

or Manuallu Publish the Migration and optionally the translations / config file

php artisan vendor:publish --tag=cd-contact-form-migrations
php artisan vendor:publish --tag=cd-contact-form-config
php artisan vendor:publish --tag=cd-contact-form-translations

php artisan migrate

(optional) Update your user model and add a the following scope:

public function scopeContactFormNotify(Builder $query): Builder
{
    return $query->where('role' , 'admin');
}

customimize the query according to your project.

If you would rather list the mail addresses, see the CD_CONTACT_FORM_NOTIFICATION_EMAILS Environmental Variable instead.

Environmental Variables

You'll need these variables set in your .env file.

NoCaptcha is used by default, you can obtain keys from Google

NamePurpose
CD_CONTACT_FORM_NOTIFICATION_EMAILSRaw email addresses that admin notifications will be sent to (comma separated)
NOCAPTCHA_SECRETThe secret for NoCaptcha
NOCAPTCHA_SITEKEYThe key for NoCaptcha

Configuration File

Many things are customisable via the published config file. Refer to documentation within the file.

Validation Rules

Validation rules can be set in the config file - under the key validation_rules and the messages under the key validation_messages

Translations

The notification emails are translatable with the following values available

Admin Notifications

  • subject: 'New message received from :Name',
  • greeting: '',
  • body_before: '### The following information was supplied',
  • body_after: '',

Customising additional field display:

in your AppServiceProvider boot method add:

AdminNotification::formatFieldsUsing(fn($name) => str($name)->replace('_', ' ')->title()->toString());