mirror of
https://github.com/v2board/v2board.git
synced 2025-01-26 16:09:09 +08:00
update
This commit is contained in:
parent
8c5b32de90
commit
76ce89c17f
37
app/Http/Controllers/Admin/MailController.php
Normal file
37
app/Http/Controllers/Admin/MailController.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Requests\Admin\MailSend;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Jobs\SendEmail;
|
||||||
|
|
||||||
|
class MailController extends Controller
|
||||||
|
{
|
||||||
|
public function send (MailSend $request) {
|
||||||
|
if ($request->input('type') == 2 && $request->input('recevicer')) {
|
||||||
|
abort(500, '收件人不能为空');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->input('recevicer')) {
|
||||||
|
$users = User::whereIn('id', $recevicer)->get();
|
||||||
|
} else {
|
||||||
|
$users = User::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($users as $user) {
|
||||||
|
SendEmail::dispatch([
|
||||||
|
'email' => $user->email,
|
||||||
|
'subject' => $subject,
|
||||||
|
'template_name' => 'mail.sendCustom',
|
||||||
|
'template_value' => [
|
||||||
|
'name' => config('v2board.app_name', 'V2Board'),
|
||||||
|
'url' => config('v2board.app_url'),
|
||||||
|
'content' => $content
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
app/Http/Requests/Admin/MailSend.php
Normal file
34
app/Http/Requests/Admin/MailSend.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class MailSend extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'type' => 'required|in:1,2',
|
||||||
|
'subject' => 'required',
|
||||||
|
'content' => 'required',
|
||||||
|
'receiver' => 'array'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'type.required' => '发送类型不能为空',
|
||||||
|
'type.in' => '发送类型格式有误',
|
||||||
|
'subject.required' => '主题不能为空',
|
||||||
|
'content.required' => '内容不能为空',
|
||||||
|
'receiver.array' => '收件人格式有误'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -54,6 +54,8 @@ Route::prefix('v1')
|
|||||||
Route::get ('ticket/fetch', 'Admin\\TicketController@fetch');
|
Route::get ('ticket/fetch', 'Admin\\TicketController@fetch');
|
||||||
Route::post('ticket/reply', 'Admin\\TicketController@reply');
|
Route::post('ticket/reply', 'Admin\\TicketController@reply');
|
||||||
Route::post('ticket/close', 'Admin\\TicketController@close');
|
Route::post('ticket/close', 'Admin\\TicketController@close');
|
||||||
|
// Mail
|
||||||
|
Route::post('mail/send', 'Admin\\MailController@send');
|
||||||
});
|
});
|
||||||
// User
|
// User
|
||||||
Route::prefix('user')
|
Route::prefix('user')
|
||||||
|
Loading…
Reference in New Issue
Block a user