composer require naux/sendcloud
config/app.php
,添加服务提供者'providers' => [
// 添加这行
Naux\Mail\SendCloudServiceProvider::class,
];
.env
中配置你的密钥, 并修改邮件驱动为 sendcloud
## 选择发送
MAIL_DRIVER=sendcloud
## SEND_CLOUD 配置
SEND_CLOUD_USER=hu243373737_test_Uf9sAJ
SEND_CLOUD_KEY=0Zv2HwgZ4FedBHJ1
应用场景:注册用户需要验证邮箱。注册的时候会发送邮件到邮箱,然后去邮箱中点击验证链接,修改激活状态,更改
token
php artisan make:auth
app/Http/Controllers/Auth/RegisterController.php
namespace App\Http\Controllers\Auth;
use Mail;
use Naux\Mail\SendCloudTemplate;
protected function create(array $data)
{
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'avatar' => 'images/avatars/default.gif',
'confirmation_token' => str_random(40),
'password' => bcrypt($data['password']),
]);
$this->sendVerifyEmailTo($user);
return $user;
}
public function sendVerifyEmailTo($user)
{
// 模板变量
$bind_data = [
'url' => route("send_email", ['token' => $user->confirmation_token]),
'name' => $user->name
];
$template = new SendCloudTemplate('test_template_active', $bind_data);
Mail::raw($template, function ($message) use ($user) {
$message->from('9265959@qq.com', 'mason');
$message->to($user->email);
});
}
public function send(Request $request)
{
$user = User::where('confirmation_token', $request->token)->first();
if (is_null($user)) {
return redirect('/');
}
$user->is_active = 1;
$user->confirmation_token = str_random(40);
$user->save();
return redirect('/home');
}
composer require laracasts/flash
config/app.php
,添加服务提供者'providers' => [
// 添加这行
Laracasts\Flash\FlashServiceProvider::class,
];
应用场景:操作成功提示用户信息
bootstrap.css
jquery.js
bootstrap.js
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello Feng</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
<div class="container">
@include("flash::message")
</div>
</body>
<script src="//code.jquery.com/jquery.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
$('#flash-overlay-modal').modal();
</script>
</html>
public function send(Request $request)
{
...
flash("邮箱验证成功!", 'success');
...
return redirect('/home');
}
composer require “overtrue/laravel-lang:~3.0”
config/app.php
,修改语言 'locale' => 'zh-CN',
composer require noisywinds/laravel-smartmd
php artisan vendor:publish --provider=“NoisyWinds\Smartmd\SmartmdServiceProvider”
## 1.引入静态资源
@include('Smartmd::head')
## 2.添加文本框区域
<div class="editor">
<textarea id="editor" placeholder="请输入正文" style="display: none"></textarea>
</div>
## 3.js渲染
<script>
var smartmd = new Smartmd({
element: document.getElementById("editor"),
minHeight: "80vh",
renderingConfig: {
singleLineBreaks: false,
codeSyntaxHighlighting: true,
},
autosave: {
enabled: true,
uniqueId: "write",
delay: 1000,
},
autoCloseTags: true,
matchTags: {bothTags: true},
image:{
uploadPath:'./upload',
type:['jpeg','png','bmp','gif','jpg'],
maxSize:4096,
}
});
if (document.body.clientWidth > 1200) {
smartmd.toggleSideBySide();
// smartmd.alert("success","preview init success");
}
</script>