/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(NotifyRequest $request) { $data = $request->all(); $data['is_system'] = 1; if (!$data['to_all'] && !$data['user_id']) { return redirect()->back()->withErrors(['请指定用户ID或发送给所有用户'])->withInput(); } Notify::notify([$request->user_id], $request->body, $request->type, $request->to_all, 1); flash()->message('发送成功!'); return redirect('/admin/notifications/index'); dd($request->all()); }
public function store(Requests\NotifyRequest $request) { //how to fetch all input and fetch each individual //Notification::create($request->all()); //$input = Request::all(); //$input = Request::get('title'); //$input['date'] = ('date'); //Store the form created //Notification::create($input); //Using auth //$notification = new Notification($request->all()); //Auth::user()->articles()->save($article); //session()->flash('flash_message', 'Your notification has been saved'); //session()->flash('flash_message_important', 'true'); //validation //Inline to make cleaner Notification::create($request->all()); flash('Notification is created'); return redirect('notifies'); //return $input; }