public function update($id, StatusRequest $request) { // find specific Status $status = Status::findOrFail($id); $status->update($request->all()); return redirect('manage/status'); }
/** * Find and return a Status only if current user is Owner. * * @param $id * @return mixed * @throws \Exception */ public function findOnlyIfOwner($id) { $status = Status::findOrFail($id); if (Auth::user() == $status->user) { return $status; } else { throw new \Exception("Not an Owner"); } }
public function storeForStatus($id, Request $request) { $status = Status::findOrFail($id); $comment = \Input::get('body'); if ($comment == '') { return \Redirect::back()->with('error', 'Comment Empty.'); } if ($request->user()->muted) { return \Redirect::back()->with('error', 'You are muted.'); } $com = $status->comments()->create(['body' => $comment, 'user_id' => Auth::user()->id]); // Own status comment if ($request->user()->id == $status->user->id) { // Create notification $not = new Notification(); $not->from($request->user())->withType('UserCommentOnStatus')->withSubject('A comment is done on status')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has commented on his own status " . link_to_route('show-status', "#" . $status->id, $status->id))->withStream(true)->regarding($com)->deliver(); } else { // Create notification $not = new Notification(); $not->from($request->user())->withType('UserCommentOnStatus')->withSubject('A comment is done on status')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has commented on " . link_to_route('user.show', $status->user->displayName(), $status->user->username) . "'s status " . link_to_route('show-status', "#" . $status->id, $status->id))->withStream(true)->regarding($com)->deliver(); $status->user->newNotification()->from($request->user())->withType('UserCommentOnStatus')->withSubject('A comment is done on status.')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has commented on your status " . link_to_route('show-status', "#" . $status->id, $status->id))->regarding($com)->deliver(); } return \Redirect::back()->with('success', 'Success! Commented on that status.'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(StatusRequest $request, $id) { $status = Status::findOrFail($id); $status->update($request->all()); return redirect('status'); }