本文整理汇总了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');
}
示例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));
}
}
}
}
}
示例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();
}
示例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();
}
}
示例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']);
}
}
}
示例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. ");
}
示例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);
}
示例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');
}
示例9: send
public function send()
{
$newMessage = new Message();
$newMessage->name = Input::get('name');
$newMessage->text = Input::get('message');
$newMessage->save();
event(new MessageSent($newMessage));
}
示例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();
}
示例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');
}
示例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');
}
示例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!');
}
示例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]);
}
}
示例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');
}