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


PHP Chat::create方法代码示例

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


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

示例1: run

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

示例2: addMessage

function addMessage($data)
{
    /* 'from_id','to_id','message','time' */
    $data['time'] = date("Y-m-d H:i:s");
    if ($c = Chat::create($data)) {
        $c['status'] = 'success';
    } else {
        $c['status'] = 'fail';
    }
    return $c;
}
开发者ID:helloworldprojects,项目名称:Autism,代码行数:11,代码来源:api.php

示例3: 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['chat'])) {
         $this->chat = isset($attributes['chat']->title) ? GroupChat::create($attributes['chat']) : User::create($attributes['chat']);
     }
     if (isset($attributes['forward_from'])) {
         $this->forward_from = User::create($attributes['forward_from']);
     }
     if (isset($attributes['forward_from_chat'])) {
         $this->forward_from_chat = Chat::create($attributes['forward_from_chat']);
     }
     if (isset($attributes['reply_to_message'])) {
         $this->reply_to_message = Message::create($attributes['reply_to_message']);
     }
     if (isset($attributes['entities'])) {
         $this->entities = array_map(function ($entity) {
             return MessageEntity::create($entity);
         }, $attributes['entities']);
     }
     if (isset($attributes['audio'])) {
         $this->audio = Audio::create($attributes['audio']);
     }
     if (isset($attributes['document'])) {
         $this->document = Document::create($attributes['document']);
     }
     if (isset($attributes['photo'])) {
         $this->photo = array_map(function ($photo) {
             return PhotoSize::create($photo);
         }, $attributes['photo']);
     }
     if (isset($attributes['sticker'])) {
         $this->sticker = Sticker::create($attributes['sticker']);
     }
     if (isset($attributes['video'])) {
         $this->video = Video::create($attributes['video']);
     }
     if (isset($attributes['voice'])) {
         $this->voice = Voice::create($attributes['voice']);
     }
     if (isset($attributes['contact'])) {
         $this->contact = Contact::create($attributes['contact']);
     }
     if (isset($attributes['location'])) {
         $this->location = Location::create($attributes['location']);
     }
     if (isset($attributes['venue'])) {
         $this->venue = Venue::create($attributes['venue']);
     }
     if (isset($attributes['new_chat_member'])) {
         $this->new_chat_member = User::create($attributes['new_chat_member']);
     }
     if (isset($attributes['left_chat_member'])) {
         $this->left_chat_member = new User($attributes['left_chat_member']);
     }
     if (isset($attributes['new_chat_photo'])) {
         $this->new_chat_photo = array_map(function ($photo) {
             return PhotoSize::create($photo);
         }, $attributes['new_chat_photo']);
     }
 }
开发者ID:zelenin,项目名称:telegram-bot-api,代码行数:67,代码来源:Message.php

示例4: doActions

 function doActions($conversation_id = null, $character_id = null)
 {
     $conversation = $this->find('first', array('conditions' => array('Conversation.id' => $conversation_id)));
     if (!empty($conversation['Quest'])) {
         App::import('Model', 'Chat');
         $Chat = new Chat();
         foreach ($conversation['Quest'] as $quest) {
             switch ($quest['ActionsConversation']['type']) {
                 case "getquest":
                     $this->Quest->bindModel(array('hasMany' => array('CharactersQuest')));
                     $this->Quest->CharactersQuest->save(array('id' => null, 'quest_id' => $quest['id'], 'character_id' => $character_id, 'completed' => 'no'));
                     // Maybe this user has already the quest done, so try to update it...
                     $this->Quest->update($quest['id'], $character_id);
                     $ChatData = array();
                     $ChatData['id'] = null;
                     $ChatData['type'] = 'system';
                     $ChatData['character_id_from'] = 0;
                     $ChatData['character_id_to'] = $character_id;
                     $ChatData['message'] = sprintf(__('Quest %s accepted.', true), '[quest]' . $quest['name'] . '[/quest]');
                     $ChatData['display'] = 'yes';
                     $Chat->create();
                     $Chat->save($ChatData);
                     $this->actionHappen = true;
                     break;
                 case "completequest":
                     $this->Quest->update($quest['id'], $character_id, true);
                     $ChatData['id'] = null;
                     $ChatData['type'] = 'system';
                     $ChatData['character_id_from'] = 0;
                     $ChatData['character_id_to'] = $character_id;
                     $ChatData['message'] = sprintf(__('Quest %s completed.', true), '[quest]' . $quest['name'] . '[/quest]');
                     $ChatData['display'] = 'yes';
                     $Chat->create();
                     $Chat->save($ChatData);
                     $this->actionHappen = true;
                     break;
             }
         }
     }
     /*
     $this->bindModel(array('hasMany' => array('ActionsConversation')));
     $someActions = $this->ActionsConversation->find('all', array('conditions' => array('ActionsConversation.conversation_id' => $conversation_id)));
     if(!empty($someActions)) {
     	App::import('Model', 'Action');
     	$Action = new Action();
     	foreach($someActions as $action) {
     		$Action->perform($action['ActionsConversation']['action_id'], $character_id);
     	}
     }
     */
 }
开发者ID:MortalROs,项目名称:Naxasius-Game-Engine,代码行数:51,代码来源:conversation.php


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