public function showeditcommentsheet($id, $commentid) { $comment = Sheetcom::find($commentid); $sheet = Sheet::find($id); if (Auth::user()->id != $comment->collaborator_id) { if (Auth::user()->id != $sheet->user_id) { Session::flash('errorMessage', 'You are not authorized to edit this comment!'); return Redirect::action('SheetsController@show', array($id)); } } return View::make('/collaboration/editcommentsheet')->with('comment', $comment)->with('sheet', $sheet); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $validator = Validator::make(Input::all(), Sheet::$rules); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } else { $sheet = Sheet::find($id); $sheet->title = Input::get('title'); $sheet->public_or_private = Input::get('public_or_private'); $sheet->user_id = Auth::user()->id; $result1 = $sheet->save(); $cluesArray = Input::get('cluesArray'); $responsesArray = Input::get('responsesArray'); $linesArray = Line::where('sheet_id', '=', $id)->lists('id'); foreach ($cluesArray as $key => $value) { if (array_key_exists($key, $linesArray)) { $line = Line::find($linesArray[$key]); } else { $line = new Line(); } $line->sheet_id = $sheet->id; $line->clue = $cluesArray[$key]; $line->response = $responsesArray[$key]; $result2 = $line->save(); } if ($result1 && $result2) { Session::flash('successMessage', 'This sheet was saved.'); // Log::info('This is some useful information.', Input::all()); return Redirect::route('sheets.index'); } else { Session::flash('errorMessage', 'This sheet was not submitted.'); return Redirect::back()->withInput(); } } }