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


PHP Message::create方法代码示例

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


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

示例1: store

 /**
  * Store a newly created conversation in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('users' => 'required|array', 'body' => 'required');
     $validator = Validator::make(Input::only('users', 'body'), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'result' => $validator->messages()]);
     }
     // Create Conversation
     $params = array('created_at' => new DateTime(), 'name' => str_random(30), 'author_id' => Auth::user()->id);
     $conversation = Conversation::create($params);
     $conversation->users()->attach(Input::get('users'));
     $conversation->users()->attach(array(Auth::user()->id));
     // Create Message
     $params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Auth::user()->id, 'created_at' => new DateTime());
     $message = Message::create($params);
     // Create Message Notifications
     $messages_notifications = array();
     foreach (Input::get('users') as $user_id) {
         array_push($messages_notifications, new MessageNotification(array('user_id' => $user_id, 'read' => false, 'conversation_id' => $conversation->id)));
         // Publish Data To Redis
         $data = array('room' => $user_id, 'message' => array('conversation_id' => $conversation->id));
         Event::fire(ChatConversationsEventHandler::EVENT, array(json_encode($data)));
     }
     $message->messages_notifications()->saveMany($messages_notifications);
     return Redirect::route('chat.index', array('conversation', $conversation->name));
 }
开发者ID:thantai574,项目名称:laravel-realtime-chat,代码行数:31,代码来源:ConversationController.php

示例2: addEmail

 public static function addEmail($from, $to, $subject, $body, array $attachments = array())
 {
     if (trim($from) === '') {
         $from = SystemSettings::getSettings(SystemSettings::TYPE_EMAIL_DEFAULT_SYSTEM_EMAIL);
     }
     return Message::create($from, $to, $subject, $body, Message::TYPE_EMAIL, $attachments);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:7,代码来源:EmailSender.php

示例3: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Message::create([]);
     }
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:7,代码来源:MessagesTableSeeder.php

示例4: run

 public function run()
 {
     Eloquent::unguard();
     Message::create(array('message_body' => 'This is a sample message that is short and to the point.', 'user_id' => '1'));
     Message::create(array('message_body' => 'Sa takie dni w tygodniu.', 'user_id' => '1'));
     Message::create(array('message_body' => 'Still working on this special project', 'user_id' => '2'));
     Message::create(array('message_body' => 'Everything I build is amazing and exceeds my own expectations.', 'user_id' => '2'));
     Message::create(array('message_body' => 'Still working on this twitter clone application.', 'user_id' => '3'));
 }
开发者ID:jtaurus,项目名称:twitter_clone,代码行数:9,代码来源:MessageSeeder.php

示例5: actionCreate

 public function actionCreate()
 {
     RoutingEngine::setPage("Messages | runnDAILY", "PV__300");
     $message = new Message($_POST);
     //TODO:add in error exception in case the message cannot be created
     if ($message->create()) {
         Message::updateCount($message->uid_to, 1);
     }
     Page::redirect("/messages");
 }
开发者ID:byronwall,项目名称:runnDAILY,代码行数:10,代码来源:messages.php

示例6: loadRelated

 /**
  * @param array $attributes
  */
 public function loadRelated(array $attributes)
 {
     parent::loadRelated($attributes);
     if (isset($attributes['from'])) {
         $this->from = User::create($attributes['from']);
     }
     if (isset($attributes['message'])) {
         $this->message = Message::create($attributes['message']);
     }
 }
开发者ID:zelenin,项目名称:telegram-bot-api,代码行数:13,代码来源:CallbackQuery.php

示例7: create

 public function create()
 {
     RoutingEngine::setPage("runnDAILY", "PV__400");
     $message = new Message($_POST);
     if ($message->message) {
         $message->uid_to = null;
         $message->subject = null;
         exit(json_encode($message->create()));
     }
     var_dump($message);
 }
开发者ID:byronwall,项目名称:runnDAILY,代码行数:11,代码来源:feedback.php

示例8: run

    public function run()
    {
        DB::table('messages')->delete();
        $now = new DateTime();
        $oneHourLater = new DateTime('+1 hour');
        $tomorrow = new DateTime('tomorrow');
        Message::create(['message' => 'This is a first message.', 'published_at' => $now]);
        Message::create(['message' => 'This is a second message. It has much more text. Lots and lots of text. I need this to test message lengths.', 'published_at' => $oneHourLater]);
        Message::create(['message' => 'This is a message with an embedded tweet. <blockquote class="twitter-tweet" lang="en"><p>The 3 day <a href="https://twitter.com/hashtag/LaraconEU?src=hash">#LaraconEU</a> Schedule can be downloaded here <a href="http://t.co/VIob78wp7S">http://t.co/VIob78wp7S</a></p>&mdash; Laracon EU (@laraconeu) <a href="https://twitter.com/laraconeu/statuses/503119817600413697">August 23, 2014</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>', 'published_at' => $oneHourLater]);
        Message::create(['message' => 'This is a message on the second day.', 'published_at' => $tomorrow]);
    }
开发者ID:anewage,项目名称:CEIT-liveblog,代码行数:12,代码来源:MessageSeeder.php

示例9: actionAdd

 public function actionAdd()
 {
     $this->pageTitle = Yii::t('page-title', 'Add new message dialog');
     $model = new Message();
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['Message'];
         if ($model->validate()) {
             $model->create();
             $this->redirect('/message/list');
         }
     }
     $this->render('add', ['model' => $model]);
 }
开发者ID:adrenalinkin,项目名称:simple-guest-book,代码行数:13,代码来源:MessageController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  * POST /contacts
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::get();
     $this->contactForm->validate($input);
     Message::create($input);
     Flash::message('Бидэнтэй холбогдож байгаад баярлалаа. Таньд удахгүй хариу мэдэгдье!');
     Mail::send('emails.question', $input, function ($message) {
         $message->to('myagmardorj_b24@yahoo.com')->subject('Ask Ganbaatar');
     });
     Mail::send('emails.question', $input, function ($message) {
         $message->to('Baagiidagwa@yahoo.com')->subject('Ask Ganbaatar');
     });
     return Redirect::back();
 }
开发者ID:PuchkaTs,项目名称:ganbaatar,代码行数:20,代码来源:ContactsController.php

示例11: sendNew

 public static function sendNew($sender, $conversation, $content, $timeOffset = 0)
 {
     $id = Message::generateId(6);
     $timestamp = Utils::tps() + $timeOffset;
     $message = Message::create(array('id' => $id, 'sender_id' => $sender, 'conversation_id' => $conversation, 'content' => $content, 'timestamp' => $timestamp));
     $recep = array();
     $members = explode(';', trim(Conversation::find($conversation)->members_ids, ';'));
     foreach ($members as $id) {
         if ($id != $sender) {
             $recep[] = trim(UserChannel::find($id)->admins_ids, ';');
         }
     }
     $recep = ';' . implode(';', $recep) . ';';
     $recep = ChannelAction::filterReceiver($recep, "pm");
     ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => userChannel::find($sender)->id, 'recipients_ids' => $recep, 'type' => 'pm', 'target' => $conversation, 'timestamp' => $timestamp));
     return $message;
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:17,代码来源:message.php

示例12: view

 public function view($common)
 {
     RoutingEngine::setPage("runnDAILY About", "PV__400");
     $pages = array("admin_elevation", "about_contact", "about_credits", "about_index", "community_index", "community_view_user", "confirmation_index", "goals_index", "goals_create", "home_index", "home_register", "messages_index", "routes_view", "routes_create", "routes_index", "training_create", "training_index");
     if (in_array($common, $pages)) {
         $output = RoutingEngine::getSmarty()->fetch("help/_pages/{$common}.tpl");
     } else {
         $feedback = new Message();
         $feedback->uid_from = User::$current_user->uid;
         $feedback->uid_to = null;
         $feedback->message = "Please create a help page for " . $_SERVER["HTTP_REFERER"];
         $feedback->subject = null;
         $feedback->type = 2;
         $feedback->create();
         $output = RoutingEngine::getSmarty()->fetch("help/_pages/none.tpl");
     }
     echo $output;
     die;
 }
开发者ID:byronwall,项目名称:runnDAILY,代码行数:19,代码来源:help.php

示例13: store

 /**
  * Store a newly created message in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('body' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'result' => $validator->messages()]);
     }
     $conversation = Conversation::where('name', Input::get('conversation'))->first();
     $params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Input::get('user_id'), 'created_at' => new DateTime());
     $message = Message::create($params);
     // Create Message Notifications
     $messages_notifications = array();
     foreach ($conversation->users()->get() as $user) {
         array_push($messages_notifications, new MessageNotification(array('user_id' => $user->id, 'conversation_id' => $conversation->id, 'read' => false)));
     }
     $message->messages_notifications()->saveMany($messages_notifications);
     // Publish Data To Redis
     $data = array('room' => Input::get('conversation'), 'message' => array('body' => Str::words($message->body, 5), 'user_id' => Input::get('user_id')));
     Event::fire(ChatMessagesEventHandler::EVENT, array(json_encode($data)));
     return Response::json(['success' => true, 'result' => $message]);
 }
开发者ID:thantai574,项目名称:laravel-realtime-chat,代码行数:26,代码来源:MessageController.php

示例14: save

 public function save(Request $request)
 {
     //1. receive the message
     /*
      * 1. Receive the message
      * 2. based on its applicatino type, If pinyin chat, exec pinyin
      * 3. Use pusher API to send back request.
      */
     $content = $request->get('message');
     $senderId = $request->get('senderId');
     $receiverID = $request->get('receiverId');
     $message = $request->all();
     $message["haveRead"] = false;
     $redis = Redis::connection();
     $senderName = $redis->hget("user" . $senderId, "name");
     //If the message type is not a keystroke track
     if (intval($message["messageType"]) == 0) {
         //This is a bug, we should fetch from database not Redis, for offline users?
         //$receiverName = $redis->hget("user".$receiverID, "name");
         //begin exec node program pinyin and get a string output.
         exec("pinyin -S " . $content, $output);
         $chinese = $this->mb_str_split($content);
         $pinyin = explode(" ", $output[0]);
         $result = "";
         for ($i = 0; $i < count($chinese); $i++) {
             $result .= '<ruby class="message">' . $chinese[$i] . '<rt class="pinyin">' . $pinyin[$i] . "</rt></ruby>";
         }
         $message["message"] = $result;
     }
     $newmessage = Message::create($message);
     //Pusher logic
     $pusher = new Pusher('c9d61998865ce108f88e', 'b1b28a9b6ffc8999bd01', '134726');
     //todo: add messageType;
     $pusher->trigger("user" . $receiverID, 'newmessage', ['senderName' => $senderName, 'message' => $message["message"], 'senderId' => $senderId, 'messageId' => $newmessage->toArray()["id"], 'timestamp' => $newmessage->toArray()["created_at"]]);
     //Create a new message and wrote to the database, set the message to not read.
     return response()->json(['senderName' => $senderName, 'message' => $message["message"], 'timestamp' => $newmessage->toArray()["created_at"]]);
 }
开发者ID:jinxuan,项目名称:CLFG,代码行数:37,代码来源:MessageController.php

示例15: addMessage

 public static function addMessage($text, $ticket = false, $ticket_id = null)
 {
     if (!isset($_SESSION['user'])) {
         throw new Exception('You are not logged in');
     }
     if (empty($text)) {
         throw new Exception('You haven\'t entered a message.');
     }
     $msg = new Message(array('user_id' => $_SESSION['user']['id'], 'text' => $text, 'created' => date('Y-m-d G:i:s')));
     if (isset($ticket_id) && is_numeric($ticket_id)) {
         $msg->ticket_id = $ticket_id;
     }
     // The create method returns the new id
     $insertID = $msg->create();
     $tick_no = null;
     if ($ticket) {
         $wlticket = new Ticket(array('message_id' => $insertID, 'title' => 'NIEUW', 'text' => $text, 'status_id' => 1));
         $tick_no = $wlticket->create();
     }
     if (isset($tick_no) && is_numeric($tick_no)) {
         $msg->setTicket($tick_no);
     }
     return array('id' => $insertID, 'ticket_id' => $msg->ticket_id);
 }
开发者ID:JJWTimmer,项目名称:BLAM,代码行数:24,代码来源:BLAM.class.php


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