/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { $aConv = Conversation::findOrFail($id); $aThread = Thread::select("*")->where("conversation_id", '=', $id)->firstOrFail(); if ($request->has('Content')) { $aConv->update($request->all()); session()->flash('flash_message', 'Conversation updated'); } else { // by definition if the conversation is validated the first thread also is if ($aConv->Pending == 1) { $aConv->Pending = 0; $aThread->Pending = 0; session()->flash('flash_message', 'Conversation is now published'); } else { $aConv->Pending = 1; $aThread->Pending = 1; session()->flash('flash_message', 'Conversation is now unpublished'); } } $aConv->save(); $aThread->save(); return redirect('dashboard'); }