$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('群發(fā)郵件');
$form = new \Encore\Admin\Widgets\Form();
$form->action('send');
$form->text('title','標題')->rules('required');
$form->textarea('content','內(nèi)容')->rules('required');
$content->body($form);
$js = SCRIPT
SCRIPT;
Admin::script($js);
return $content;
}