$router->get('mails/send', 'MailController@send');
$router->post('mails/send', 'MailController@send');
public function send(Content $content)
{
//添加请求
if (request()->isMethod('post')) {
//验证
$data = request()->post();
$validate = Validator::make($data, [
'title' => 'required|max:125',
'content' => 'required'
]);
//处理
if ($validate->fails()) {
$content->withWarning('提醒', $validate);
} else {
Mail::create($data);
$content->withSuccess('提醒', '操作成功');
return redirect('/admin/mails');
}
}
$content->header('群发邮件');
$form = new \Encore\Admin\Widgets\Form();
$form->action('send');
$form->text('title','标题')->rules('required');
$form->textarea('content','内容')->rules('required');
$content->body($form);
$js = SCRIPT
SCRIPT;
Admin::script($js);
return $content;
}