omh / laracontact
Laravel应用程序的联系我们表单
1.0.2
2020-01-21 17:20 UTC
Requires
- php: ^7.2
- guzzlehttp/guzzle: ^6.5
- illuminate/support: ^6.0
Requires (Dev)
- orchestra/testbench: 4.*
This package is auto-updated.
Last update: 2024-09-22 03:41:48 UTC
README
Laracontact
Laracontact是一个带有Google reCaptcha V2垃圾邮件保护的Laravel应用程序的联系我们表单。
该包将(姓名、电子邮件、主题和消息)的联系人请求存储在数据库中,并通过电子邮件发送给管理员。
安装
composer require omh/laracontact
- 服务提供程序将自动注册。或者,您可以在config/app.php文件中手动添加服务提供程序
'providers' => [ // ... Laracontact\LaracontactServiceProvider::class, ];
- 您应该使用以下命令发布迁移和config/contact_request.php配置文件
php artisan vendor:publish --tag="laracontact-migration" php artisan vendor:publish --tag="laracontact-config"
- 在配置和迁移已发布并配置后,您可以通过运行迁移来创建contact_requests表
php artisan migrate
用法
联系我们表单默认在/contact-us
可用
您可以在配置文件中自定义表单路径。
默认配置文件内容
return [ /* * Set the form path. */ 'form_path' => '/contact-us', /* * Set the url redirection after submitting the contact us form. */ 'redirectTo' => '/', /* * Set the contact us page title. */ 'page_title' => 'Contact us', /* * Array of emails that should receive the contact request */ 'notifiables' => ['admin@test.test'], /* * Set to false to disable sending emails feature */ 'send_mails' => true, /* * To configure correctly please visit https://developers.google.com/recaptcha/docs/start */ 'recaptcha' => [ /* * * The secret key * get site key @ www.google.com/recaptcha/admin * */ 'recaptcha_secret' => env('RECAPTCHA_SECRET'), /* * * The secret key * get site key @ www.google.com/recaptcha/admin * */ 'recaptcha_sitekey' => env('RECAPTCHA_SITEKEY'), ] ];
- 您可以在联系提交后更改重定向URL
/* * Set the url redirection after submitting the contact us form. */ 'redirectTo' => '/my-custom-redirection',
- 您可以更改联系我们页面的标题
/* * Set the url redirection after submitting the contact us form. */ 'page_title' => 'My Custome title',
- 您可以在通知数组中添加管理员的电子邮件
/* * Array of emails that should receive the contact request */ 'notifiables' => ['admin@test.test'],
- 您可以通过设置
'send_emails'
为false来禁用发送电子邮件
/* * Set to false to disable sending emails feature */ 'send_mails' => false,
自定义联系我们表单
如果您想自定义联系我们表单,可以运行
php artisan vendor:publish --tag="laracontact-views"
现在视图将位于resources/views/vendor/contact_request/
目录中
使用您自己的可邮寄/通知者
每当提交联系人请求时,都会触发一个Laracontact\Events\ContactRequestEvent
事件。您可以在app/Providers/EventServiceProvider.php
文件中添加监听器并触发您自己的可邮寄对象
/** * The event listener mappings for the application. * * @var array */ protected $listen = [ Laracontact\Events\ContactRequestEvent::class => [ // your own listeners ], ];