public function store(Request $request, $id) { $user = \Auth::user(); $input = Request::all(); $forms = Form::findorfail($id); Comment::create(['content' => $input['content'], 'user_id' => $user->id, 'form_id' => $forms->id]); return redirect(url('/form', $id)); }
public function store(Request $request, $id) { $user = \Auth::user(); $form = Form::findorfail($id); $input = Request::all(); Message::create(['user_id' => $user['id'], 'form_id' => $form['id'], 'content' => $input['content'], 'type' => $input['type']]); return redirect('/form'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request, $id) { $submission = new Submission(); $form = Form::findorfail($id); if ($form->validateInputs($request)) { $inputs = $request->all(); // We don't need the CSRF token, so drop it unset($inputs['_token']); $submission->submission = $this->prepareSubmission($inputs, $form); $submission->form_id = $id; $submission->save(); Event::fire(new FormWasSubmitted($form, $submission)); return view('submissions.confirmation', ['form' => $form, 'submission' => $submission]); } else { dd('validation failed'); } }
public function like(Request $request, $id) { if (\Auth::check()) { $forms = Form::findorfail($id); $userid = \Auth::user(); Like::create(['user_id' => $userid->id, 'form_id' => $forms->id]); $likes = Like::all(); $likedata = $this->countLikes($likes, $forms); echo json_encode($likedata); } else { return redirect('auth/login'); } }