mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
feature: new send mail
This commit is contained in:
parent
bbdda28197
commit
16ae59c992
@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
|
||||||
|
|
||||||
use App\Http\Requests\Admin\MailSend;
|
|
||||||
use App\Services\UserService;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Jobs\SendEmailJob;
|
|
||||||
|
|
||||||
class MailController extends Controller
|
|
||||||
{
|
|
||||||
public function send(MailSend $request)
|
|
||||||
{
|
|
||||||
$userService = new UserService();
|
|
||||||
$users = [];
|
|
||||||
switch ($request->input('type')) {
|
|
||||||
case 1: $users = $userService->getAllUsers();
|
|
||||||
break;
|
|
||||||
case 2: $users = $userService->getUsersByIds($request->input('receiver'));
|
|
||||||
break;
|
|
||||||
// available users
|
|
||||||
case 3: $users = $userService->getAvailableUsers();
|
|
||||||
break;
|
|
||||||
// un available users
|
|
||||||
case 4: $users = $userService->getUnAvailbaleUsers();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($users as $user) {
|
|
||||||
SendEmailJob::dispatch([
|
|
||||||
'email' => $user->email,
|
|
||||||
'subject' => $request->input('subject'),
|
|
||||||
'template_name' => 'notify',
|
|
||||||
'template_value' => [
|
|
||||||
'name' => config('v2board.app_name', 'V2Board'),
|
|
||||||
'url' => config('v2board.app_url'),
|
|
||||||
'content' => $request->input('content')
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response([
|
|
||||||
'data' => true
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,9 @@ namespace App\Http\Controllers\Admin;
|
|||||||
|
|
||||||
use App\Http\Requests\Admin\UserFetch;
|
use App\Http\Requests\Admin\UserFetch;
|
||||||
use App\Http\Requests\Admin\UserGenerate;
|
use App\Http\Requests\Admin\UserGenerate;
|
||||||
|
use App\Http\Requests\Admin\UserSendMail;
|
||||||
use App\Http\Requests\Admin\UserUpdate;
|
use App\Http\Requests\Admin\UserUpdate;
|
||||||
|
use App\Jobs\SendEmailJob;
|
||||||
use App\Utils\Helper;
|
use App\Utils\Helper;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
@ -208,4 +210,29 @@ class UserController extends Controller
|
|||||||
}
|
}
|
||||||
echo $data;
|
echo $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sendMail(UserSendMail $request)
|
||||||
|
{
|
||||||
|
$sortType = in_array($request->input('sort_type'), ['ASC', 'DESC']) ? $request->input('sort_type') : 'DESC';
|
||||||
|
$sort = $request->input('sort') ? $request->input('sort') : 'created_at';
|
||||||
|
$userModel = User::orderBy($sort, $sortType);
|
||||||
|
$this->filter($request, $userModel);
|
||||||
|
$users = $userModel->get();
|
||||||
|
foreach ($users as $user) {
|
||||||
|
SendEmailJob::dispatch([
|
||||||
|
'email' => $user->email,
|
||||||
|
'subject' => $request->input('subject'),
|
||||||
|
'template_name' => 'notify',
|
||||||
|
'template_value' => [
|
||||||
|
'name' => config('v2board.app_name', 'V2Board'),
|
||||||
|
'url' => config('v2board.app_url'),
|
||||||
|
'content' => $request->input('content')
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response([
|
||||||
|
'data' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ class KnowledgeController extends Controller
|
|||||||
$knowledge['body'] = str_replace('{{appleId}}', $appleId, $knowledge['body']);
|
$knowledge['body'] = str_replace('{{appleId}}', $appleId, $knowledge['body']);
|
||||||
$knowledge['body'] = str_replace('{{appleIdPassword}}', $appleIdPassword, $knowledge['body']);
|
$knowledge['body'] = str_replace('{{appleIdPassword}}', $appleIdPassword, $knowledge['body']);
|
||||||
$knowledge['body'] = str_replace('{{subscribeUrl}}', $subscribeUrl, $knowledge['body']);
|
$knowledge['body'] = str_replace('{{subscribeUrl}}', $subscribeUrl, $knowledge['body']);
|
||||||
|
$knowledge['body'] = str_replace('{{urlEncodeSubscribeUrl}}', urlencode($subscribeUrl), $knowledge['body']);
|
||||||
return response([
|
return response([
|
||||||
'data' => $knowledge
|
'data' => $knowledge
|
||||||
]);
|
]);
|
||||||
|
29
app/Http/Requests/Admin/UserSendMail.php
Normal file
29
app/Http/Requests/Admin/UserSendMail.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UserSendMail extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'subject' => 'required',
|
||||||
|
'content' => 'required',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'subject.required' => '主题不能为空',
|
||||||
|
'content.required' => '发送内容不能为空'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -69,6 +69,7 @@ class AdminRoute
|
|||||||
$router->get ('/user/getUserInfoById', 'Admin\\UserController@getUserInfoById');
|
$router->get ('/user/getUserInfoById', 'Admin\\UserController@getUserInfoById');
|
||||||
$router->post('/user/generate', 'Admin\\UserController@generate');
|
$router->post('/user/generate', 'Admin\\UserController@generate');
|
||||||
$router->post('/user/dumpCSV', 'Admin\\UserController@dumpCSV');
|
$router->post('/user/dumpCSV', 'Admin\\UserController@dumpCSV');
|
||||||
|
$router->post('/user/sendMail', 'Admin\\UserController@sendMail');
|
||||||
// Stat
|
// Stat
|
||||||
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
|
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
|
||||||
// Notice
|
// Notice
|
||||||
@ -80,8 +81,6 @@ class AdminRoute
|
|||||||
$router->get ('/ticket/fetch', 'Admin\\TicketController@fetch');
|
$router->get ('/ticket/fetch', 'Admin\\TicketController@fetch');
|
||||||
$router->post('/ticket/reply', 'Admin\\TicketController@reply');
|
$router->post('/ticket/reply', 'Admin\\TicketController@reply');
|
||||||
$router->post('/ticket/close', 'Admin\\TicketController@close');
|
$router->post('/ticket/close', 'Admin\\TicketController@close');
|
||||||
// Mail
|
|
||||||
$router->post('/mail/send', 'Admin\\MailController@send');
|
|
||||||
// Coupon
|
// Coupon
|
||||||
$router->get ('/coupon/fetch', 'Admin\\CouponController@fetch');
|
$router->get ('/coupon/fetch', 'Admin\\CouponController@fetch');
|
||||||
$router->post('/coupon/save', 'Admin\\CouponController@save');
|
$router->post('/coupon/save', 'Admin\\CouponController@save');
|
||||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user