当前位置: 首页>>代码示例>>PHP>>正文


PHP Message::save方法代码示例

本文整理汇总了PHP中app\Message::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::save方法的具体用法?PHP Message::save怎么用?PHP Message::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Message的用法示例。


在下文中一共展示了Message::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveDiscussion

 /**
  * Save message to Discussion page
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function saveDiscussion()
 {
     $input = Input::all();
     $message = new Message();
     $message->body = $input['message'];
     $message->user_id = Auth::user()->id;
     // Storing image file, if it is attached
     if (Input::hasFile('image')) {
         $file = Input::file('image');
         if ($file->isValid()) {
             $filename = rand(111111, 999999) . '-' . $file->getClientOriginalName();
             $destination_path = 'uploads/projects/';
             $file->move($destination_path, $filename);
             $message->attachment = $filename;
             // Make a thumbnail picture
             $thumbnail = Image::make($destination_path . '/' . $filename);
             $thumbnail->resize(55, null, function ($constraint) {
                 $constraint->aspectRatio();
             });
             $thumbnail->save('uploads/projects/thumbnails/' . $filename);
         }
     }
     $message->save();
     return redirect('/projects/discussion');
 }
开发者ID:AlexAustralia,项目名称:printflow,代码行数:30,代码来源:ProjectsController.php

示例2: createMessage

 protected function createMessage($from, $msg)
 {
     echo sprintf('User %d sending message "%s" to user %d' . "\n", $from->userId, $msg->message, $msg->userTo);
     $dialog = new Dialog();
     $dialog->from = $from->userId;
     $dialog->to = $msg->userTo;
     if ($dialog->validate()) {
         if (($existedDialog = Dialog::byUsers($dialog->from, $dialog->to)->first()) === null) {
             $dialog->save();
             $existedDialog = $dialog;
         }
         $message = new Message();
         $message->from = $from->userId;
         $message->dialog_id = $existedDialog->id;
         $message->text = $msg->message;
         if ($message->validate()) {
             $message->save();
             foreach ($this->clients as $client) {
                 if ($client->userId == $from->userId || $client->userId == $msg->userTo || $client->isAdmin === true) {
                     $view = view('chat._message', ['messages' => [$message], 'isAdmin' => $client->isAdmin]);
                     $sendData = ['action' => Message::CREATE_ACTION_NAME, 'html' => $view->render()];
                     $client->send(json_encode($sendData));
                 }
             }
         }
     }
 }
开发者ID:viktory,项目名称:chat,代码行数:27,代码来源:Chat.php

示例3: Post

 public function Post(Request $request)
 {
     $recaptcha = new \ReCaptcha\ReCaptcha('6LfWHfkSAAAAAMj0Kkhn1FJV6y-RiSZ_M9rasufn');
     $resp = $recaptcha->verify($request->input('g-recaptcha-response'), $request->ip());
     $msgValidation = trim(strip_tags(str_replace(" ", ' ', $request->input('message'))));
     $username = trim(strip_tags(str_replace(" ", ' ', $request->input('name'))));
     $errors = [];
     if (!Auth::check() && strlen($username) < 3) {
         array_push($errors, 'Veuillez saisir un nom d\'utilisateur d\'au moins 3 caractères svp !');
     }
     if (strlen($msgValidation) == 0) {
         array_push($errors, 'Le message est obligatoire !');
     }
     if (!$resp->isSuccess()) {
         array_push($errors, 'Veuillez renseigner le captcha svp !');
     }
     if (count($errors) == 0) {
         $msg = new Message();
         if (Auth::check()) {
             $msg->author_id = $request->user()->id;
         } else {
             $msg->username = $username;
         }
         $msg->message = $msgValidation;
         $msg->remote_addr = $request->ip();
         $msg->save();
         return redirect()->route('minichat');
     }
     Session::flash('errors', $errors);
     return redirect()->route('minichat')->withInput();
 }
开发者ID:kbiyo,项目名称:ARTTv2,代码行数:31,代码来源:MinichatController.php

示例4: doCreate

 public function doCreate(CreateMessageRequest $request)
 {
     $message = new Message();
     $message->sender = \Auth::user()->id;
     $message->receiver = $request->employee;
     $message->subject = $request->subject;
     $message->time = \Carbon\Carbon::now()->toTimeString();
     try {
         if ($message->save()) {
             $messageReply = new MessageReply();
             $messageReply->sender = \Auth::user()->id;
             $messageReply->msg_id = $message->id;
             $messageReply->text = $request->message;
             $messageReply->time = \Carbon\Carbon::now()->toTimeString();
             if ($messageReply->save()) {
                 if ($request->file('attachment')) {
                     $messageReply->is_attachment = 1;
                     $messageReply->save();
                     $extension = $request->file('attachment')->getClientOriginalExtension();
                     $request->file('attachment')->move(public_path('uploads/inbox/' . $message->id . '/'), $messageReply->id . '.' . $extension);
                 }
             }
         }
         return redirect()->back()->with('message', 'Message has been sent successfully !');
     } catch (ParseException $ex) {
         echo 'Failed to send message , with error message: ' . $ex->getMessage();
     }
 }
开发者ID:m-gamal,项目名称:crm,代码行数:28,代码来源:InboxController.php

示例5: onMessage

 /**
  * Triggered when a client sends data through the socket
  * @param  \Ratchet\ConnectionInterface $client The socket/connection that sent the message to your application
  * @param  string $msg The message received
  * @throws \Exception
  */
 function onMessage(ConnectionInterface $client, $msg)
 {
     $msg = json_decode($msg, true);
     if (isset($msg['command'])) {
         switch ($msg['command']) {
             case 'setUser':
                 $this->setUserClient(isset($msg['token']) ? $msg['token'] : null, $client);
             default:
         }
     } else {
         if (isset($msg['from']) && isset($msg['to']) && isset($msg['text'])) {
             if (!isset($this->resourceUsers[$client->resourceId])) {
                 $client->close();
                 return;
             }
             $from = $this->resourceUsers[$client->resourceId]->id;
             $message = new Message();
             $message->setAttribute('sender_id', $from);
             $message->setAttribute('recipient_id', $msg['to']);
             $message->setAttribute('text', $msg['text']);
             $message->save();
             $recipient = isset($this->userClients[$msg['to']]) ? $this->userClients[$msg['to']] : null;
             if ($recipient instanceof ConnectionInterface) {
                 $recipient->send($message->toJson());
             }
             $client->send($message->toJson());
             echo sprintf('Connection %d sending message "%s" to %d' . "\n", $from, $msg['text'], $msg['to']);
         }
     }
 }
开发者ID:paulchyrilov,项目名称:hello_laravel,代码行数:36,代码来源:ChatController.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Message $message)
 {
     $toggle = $message->viewed ? 0 : 1;
     $message->viewed = $toggle;
     $message->save();
     return redirect()->route('admin.messages.index')->withSuccess("The Message [{$message->message}] has been marked as viewed. ");
 }
开发者ID:Yismen,项目名称:ruta-cj27,代码行数:14,代码来源:MessagesController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $message = new Message();
     $message->fill($request->all());
     // Mass Assignment
     $message->save();
     return response()->json(["status" => "Mensagem Criada com Sucesso!", "message" => $message], 200);
 }
开发者ID:williamfunchal,项目名称:SocialBaseTest,代码行数:14,代码来源:MessagesController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $message = new Message();
     $message->name = Input::get('username');
     $message->message = Input::get('message');
     $message->save();
     return Redirect::to('/message');
 }
开发者ID:Chiene,项目名称:Laravel_basic_tutorial,代码行数:14,代码来源:MessageBoardController.php

示例9: send

 public function send()
 {
     $newMessage = new Message();
     $newMessage->name = Input::get('name');
     $newMessage->text = Input::get('message');
     $newMessage->save();
     event(new MessageSent($newMessage));
 }
开发者ID:bouchardm,项目名称:chatapp,代码行数:8,代码来源:ChatController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param CreateMessageRequest $request
  * @return Response
  */
 public function store(CreateMessageRequest $request)
 {
     $message = new Message();
     $message->fill($request->all());
     $message->save();
     Flash::info(trans('messages.message_sent_successfully'));
     return redirect()->back();
 }
开发者ID:jrafaelca,项目名称:infrea,代码行数:14,代码来源:MessagesController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $message = new Message();
     $message->messageTitle = $request->messageTitle;
     $message->messageText = $request->messageText;
     $message->messageLink = $request->messageLink;
     $message->messageColor = $request->messageColor;
     $message->save();
     return \Redirect::route('message.index');
 }
开发者ID:christengc,项目名称:wheel,代码行数:16,代码来源:MessagesController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $message = new Message();
     $id = md5($request->input('message_title') . $request->input('message_content'));
     $message->message_id = $id;
     $message->message_title = $request->input('message_title');
     $message->message_content = $request->input('message_content');
     $message->save();
     return view('pages.home');
 }
开发者ID:kuzoncby,项目名称:CRUD-Laravel-5-Message-Board,代码行数:16,代码来源:MessageController.php

示例13: store

 /**
  * Store a newly created message in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $data = new Message();
     $data->name = $request['name'];
     $data->email = $request['email'];
     $data->message = $request['message'];
     $data->save();
     $id = $data->id;
     $this->send($id);
     return Redirect::to('/')->with('success', 'Je bericht werd verzonden!');
 }
开发者ID:janhenckens,项目名称:herpakken,代码行数:16,代码来源:MessageController.php

示例14: saveMessage

 public function saveMessage()
 {
     if (Request::ajax()) {
         $data = Input::all();
         $message = new Message();
         $message->author = $data["author"];
         $message->message = $data["message"];
         $message->save();
         Pusher::trigger('chat', 'message', ['message' => $message]);
     }
 }
开发者ID:huseyinbabal,项目名称:RealtimeChatLaravel,代码行数:11,代码来源:ChatController.php

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $mail = new Message();
     $mail->sender = $request->name;
     $mail->email = $request->email;
     $mail->subject = $request->subject;
     $mail->message = $request->message;
     $mail->save();
     \Session::flash('flash_message', 'Message Sent');
     return redirect('contact.create');
 }
开发者ID:benjaminsweetnam247,项目名称:Laravel-Blog-Portfolio,代码行数:17,代码来源:MailController.php


注:本文中的app\Message::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。