agelxnash / l4-confirm-action
Laravel 4 确认用户操作
dev-master
2014-05-05 12:43 UTC
Requires
- php: >=5.3.0
- illuminate/support: ~4
This package is auto-updated.
Last update: 2024-08-25 06:52:47 UTC
README
将l4-confirm-action添加到您的composer.json文件中
"require": {
"agelxnash/l4-confirm-action": "dev-master"
}
现在,从项目的根目录运行命令行中的composer update
composer update
注册包
将L4ConfirmAction Service Provider添加到您的配置文件app/config/app.php
'providers' => array( 'AgelxNash\L4ConfirmAction\ConfirmServiceProvider' ),
如果您使用Package Installer,您可以运行php artisan package:install agelxnash/l4-confirm-action
发布配置
从项目的根目录运行以下命令行:php artisan config:publish agelxnash/l4-confirm-action
这会将L4ConfirmAction的配置发布到app/config/packages/agelxnash/l4-confim-action/
如果您想更改操作逻辑,也可以更改'classname'
的值。
迁移
现在迁移L4ConfirmAction的数据库表。从项目的根目录运行以下命令行:php artisan migrate --package="agelxnash/l4-confirm-action"
您必须有一个具有无符号id字段的InnoDB表users
使用方法
发送确认邮件操作替换
$userObj = Auth::user(); $newMail = 'test@example.com'; $newHash = ConfirmUserAction::createHash($userObj->id, 'newMail', $newMail); \Mail::send('emails.newMail', array( 'hash' => $newHash 'userObj' => $userObj->id ), function($message) use ($obj, $newMail){ $message->from(Config::get('mail.from.address')) ->to($newMail) ->subject('Confirmation email change'); }); \Mail::send('emails.oldMail', array( 'hash' => CChop\Helpers\User::confirum($userObj->id, 'oldMail', $userObj->email), 'userObj' => $userObj, 'newMail' => $newMail ), function($message) use ($userObj){ $message->from(Config::get('mail.from.address')) ->to($userObj->email) ->subject('Notice of the request for a change of your email'); } );
emails.newMail blade
Change e-mail: {{ URL::route('confirum', compact('hash')) }}
emails.oldMail blade
Cancels the request to change email: {{ URL::route('confirum', compact('hash')) }} To confirm the change, open a link from a letter sent by mail: {{ $newMail }}