本文整理汇总了PHP中app\Message::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::find方法的具体用法?PHP Message::find怎么用?PHP Message::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Message
的用法示例。
在下文中一共展示了Message::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: markAsRead
public function markAsRead($id)
{
$message = Message::find($id);
$message->read = 1;
$message->save();
return $this->response();
}
示例2: setMessageOpened
/**
* Sets a user's message to opened.
* @since 0.1.0
*/
public function setMessageOpened($id)
{
$message = Message::find($id);
$message->opened = true;
$message->save();
return $message;
}
示例3: destroy
public function destroy($id)
{
$message = Message::find($id);
if (count($message) > 0) {
return Message::destroy($id);
}
abort(204);
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$message = Message::find($id);
if (count($message) > 0) {
return response()->json($message);
}
abort(204);
}
示例5: send
/**
* Send an email with the saved message.
*
* @param $id
* @return Response
*/
public function send($id)
{
$payload = Message::find($id);
$data = array('email' => $payload->email, 'name' => $payload->name, 'content' => $payload->message);
Mail::send('notifications.herpakken', $data, function ($message) use($data) {
$message->to($data['email'], $data['name'])->from('info@herpakken.be')->subject('Tijd om je te herpakken!');
});
}
示例6: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$message = Message::find($id);
if (is_null($message)) {
return response()->json(["status" => "Mensagem não encontrada"], 400);
}
$message->delete();
return response()->json($message);
}
示例7: changeSubject
/**
* @param $message_id
* @param Request $request
*
* @return mixed
* @throws NotFoundException
*/
public function changeSubject($message_id, Request $request)
{
$this->validate($request, ['subject' => 'required']);
if ($message = Message::find($message_id)) {
$message->update($request->get('subject'));
return $this->respondSuccess('Subject successfully updated', ['message' => Fractal::item($message, new MessageTransformer())]);
}
throw new NotFoundException();
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$message = Message::find($request->route()->getParameter('id'));
if ($message) {
$message->read = 1;
$message->save();
}
return $next($request);
}
示例9: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$msgObj = Message::find($id);
$msgObj->read = 1;
$msgObj->save();
$data = array('type' => 'noreadprivatemsg', 'dest' => $msgObj->to);
event(new MyEventNameHere($data));
$sender = User::find($msgObj->from);
return view('messages.detail', compact('msgObj', 'sender'));
}
示例10: comments
/**
* 评论
* @return bool
*/
public function comments(Request $request)
{
$comment = new Comment();
$comment->content = $request->content;
$comment->message_id = $request->message_id;
$comment->user_id = Auth::id();
$comment->message_user_id = Message::find($request->message_id)['user_id'];
$comment->save();
return Redirect('/message_info' . '/' . $request->message_id);
}
示例11: update
/**
* Actualiza la formación de un mensaje es específico
*
* @param MessageRequest $request -> valida los campos requeridos para actualizar un mensaje
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(MessageRequest $request, $id)
{
/* encuentra el mensaje basado en su id (select * from messages where id = $id) */
$message = Message::find($id);
/* $request->all() trae todos los datos que fueron ingresados en la forma */
/* $message->fill() Actualiza sólo los campos que se encuentran en $request->all() */
$message->fill($request->all());
/* guarda los cambios */
$message->save();
/* retorno a el listado de mensajes */
return redirect('msgs');
}
示例12: viewMessage
public function viewMessage($id)
{
$message = Message::find($id);
if (!Auth::check()) {
return Redirect::to('/login');
} else {
if (Auth::user()->id != $message->receiver_id) {
return Redirect::to('/inbox');
}
}
DB::table('messages')->where('id', $id)->update(['read' => true]);
return view('message', ['message' => $message]);
}
示例13: chat
public function chat()
{
$receiverId = Input::get('receiver');
DB::beginTransaction();
$message = Message::create(['sender' => Session::get(MateMiddleware::$VERIFY), 'receiver' => $receiverId, 'content' => Input::get('content')]);
$mate = Mate::find($receiverId);
$mate->inform = true;
$mate->save();
DB::commit();
$result = Message::find($message->id);
//$result = ['id'=>$message->id, 'sender'=>$message->sender, 'receiver'=>$message->receiver, 'content'=>$message->content, 'edit'=>$message->edit];
return $result;
}
示例14: onMessage
public function onMessage(ConnectionInterface $from, $msg)
{
$msg = json_decode($msg);
if (isset($msg->action)) {
if ($msg->action == Message::CREATE_ACTION_NAME) {
$this->createMessage($from, $msg);
} elseif (isset($msg->id) && $msg->action == Message::DELETE_ACTION_NAME) {
if (($message = Message::find($msg->id)) !== null) {
$this->deleteMessage($message);
}
}
}
}
示例15: deleteMessage
/**
* Remove message from Discussion
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function deleteMessage()
{
$input = Input::all();
$message = Message::find($input['delete']);
if (!is_null($message->attachment)) {
$image = 'uploads/projects/' . $message->attachment;
$thumbnail = 'uploads/projects/thumbnails/' . $message->attachment;
if (file_exists($image)) {
unlink($image);
}
if (file_exists($thumbnail)) {
unlink($thumbnail);
}
}
$message->delete();
return redirect('/projects/discussion');
}