custom-d / cd-contact-form
Base Contact form package for laravel installs
Requires
- php: ^8.1
- anhskohbo/no-captcha: ^3.4
- illuminate/contracts: ^9.0|^10.0|^11.0
- phpsa/laravel-api-controller: *
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- nunomaduro/collision: ^6.0|^7.0|^8.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0|^8.0|^9.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpsa/laravel-api-controller: >=5.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5|^10.0
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
Name | Purpose |
---|---|
CD_CONTACT_FORM_NOTIFICATION_EMAILS | Raw email addresses that admin notifications will be sent to (comma separated) |
NOCAPTCHA_SECRET | The secret for NoCaptcha |
NOCAPTCHA_SITEKEY | The 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());