Adds a new message to a current thread.

@param $id
@return mixed
189346
public function update($id)
    {
        try {
            $thread = Thread::findOrFail($id);
        } catch (ModelNotFoundException $e) {
            Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');

            return redirect()->route('messages');
        }

        $thread->activateAllParticipants();

        // Message
        Message::create([
            'thread_id' => $thread->id,
            'user_id' => Auth::id(),
            'body' => Input::get('message'),
        ]);

        // Add replier as a participant
        $participant = Participant::firstOrCreate([
            'thread_id' => $thread->id,
            'user_id' => Auth::id(),
        ]);
        $participant->last_read = new Carbon;
        $participant->save();

        // Recipients
        if (Input::has('recipients')) {
            $thread->addParticipant(Input::get('recipients'));
        }

        return redirect()->route('messages.show', $id);
    }
352747
public function actionReply($id)
    {
        $comment = $this->findModel($id);
        if (!\Yii::$app->user->can('replyStranger', ['comment' => $comment]))
            return $this->alert(\Yii::t('app', 'Access denied.'));
        
        // fill in a new Comment
        $model = $this->newModel();
        $model->model = $comment->model;
        $model->parent_id = $comment->parent_id;
        $model->thread = $comment->thread;
        $model->user_id = \Yii::$app->user->id; // comment of a current user
        $model->status = Comment::STATUS_APPROVED; // comment approved by default
        $model->last = 1; // only the last comment in the thread can be replied

        if ($model->load(\Yii::$app->request->post()) && $model->save()) {
            // the comment to which we reply must be approved
            if ($comment->status == Comment::STATUS_PENDING) {
                $comment->status = Comment::STATUS_APPROVED;
                $comment->save(false);
            }
            return YII_DEBUG 
                ? $this->redirect(['index'])
                : $this->redirect(\Yii::$app->request->referrer);
        } else {
            return $this->renderAjax('reply', [
                'model' => $model,
                'comment' => $comment,
            ]);
        }
    }
522022
public function update($id, $data)
    {
        $message = $this->client->put(
            sprintf('buckets/%d/messages/%d.json', $this->bucket, $id),
            [
                'json' => $data,
            ]
        );

        return new Message($this->response($message));
    }
282126
public function addWidget($id)
    {
        if (!(int)$id) return $this;
        $this->widgets[] = $this->application->getWidget( (int)$id );
        return $this;  
    }
694436
protected function __apiUpdate (string $id)
    {
        $record = HCResources::findOrFail ($id);

        $data = $this->getInputData ();

        $record->update (array_get ($data, 'record'));

        return $this->apiShow ($record->id);
    }
376468
public function show($id)
    {
        try {
            $thread = Thread::findOrFail($id);
        } catch (ModelNotFoundException $e) {
            Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');

            return redirect('message');
        }

        // show current user in list if not a current participant
        // $users = User::whereNotIn('id', $thread->participantsUserIds())->get();

        // don't show the current user in list
        $userId = Auth::user()->id;
        $users = User::whereNotIn('id', $thread->participantsUserIds($userId))->get();

        $thread->markAsRead($userId);

        return view('chat.show', compact('thread', 'users'));
    }
542117
public function notificationAction($id)
    {
        /** @var PostInterface $post */
        $post = $this->get('opifer.form.post_manager')->getRepository()->find($id);

        if (!$post) {
            return $this->createNotFoundException();
        }

        $form = $post->getForm();

        /** @var Mailer $mailer */
        $mailer = $this->get('opifer.form.mailer');
        $mailer->sendNotificationMail($form, $post);

        $this->addFlash('success', 'Notification mail sent successfully');

        return $this->redirectToRoute('opifer_form_post_index', ['formId' => $form->getId()]);
    }
665632
public function update($id)
    {
        $parameters = $this->validateRequest(true);
        $model = $this->repository->update($id, $parameters);
        return $this->modelResponse($model);
    }
450849
public static function get_handler_from_id($id) {
        global $DB;

        $record = $DB->get_record('messageinbound_handlers', array('id' => $id), '*', IGNORE_MISSING);
        if (!$record) {
            return false;
        }
        return self::handler_from_record($record);
    }
960181
public function markEmailAsRead($id) {

        $emailMessage = $this->model->find($id);

        $emailMessage->read = 1;

        return $emailMessage->save();
    }
528894
public function read($id)
    {
        $thread = Thread::find($id);
        if (!$thread) {
            abort(404);
        }

        $thread->markAsRead(Auth::id());
    }
1153681
public function getThreadSubscription(int $id): array
    {
        return $this->getApi()->request($this->getApi()
                                             ->sprintf('/notifications/threads/:id/subscription', (string)$id));
    }
1067870
public function update($id)
    {
        $user = $this->userRepo->getById($id);
        if (!empty($user)) {
            $this->authorize('update', $user);
            $input = $this->validator->bind('nick', ['user_id' => $user->id])->bind('email', ['user_id' => $user->id])
                ->validate('update');
            $user  = $this->userRepo->update($user, $input);
            return $this->respondWithSuccess($user, new UserTransformer());
        }
        return $this->respondNotFound();
    }
452334
public function delete($id) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Position not found.']);
		}

		// delete
		$this->dispatch(PositionEvent::PRE_DELETE, $model);
		$model->delete();

		if ($model->isDeleted()) {
			$this->dispatch(PositionEvent::POST_DELETE, $model);
			return new Deleted(['model' => $model]);
		}

		return new NotDeleted(['message' => 'Could not delete Position']);
	}
543049
public function threadsWithNewMessages()
    {
        return $this->threads()
            ->where(function (Builder $q) {
                $q->whereIn(Models::table('threads') . '.id', $this->unreadMessages()->pluck('thread_id'));
            })
            ->get();
    }
230198
public function show($id)
    {
        $message = $this->client->get(
            sprintf('buckets/%d/messages/%d.json', $this->bucket, $id)
        );

        return new Message($this->response($message));
    }
104040
public function lock($id)
    {
        $id = (int) $id;
        if ($id <= 0) {
            throw new Exception('Invalid param id');
        }
        return $this->rest->put("$this->action/$id/lock");
    }