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


PHP Channel::where方法代码示例

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


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

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $interactor = new CurlInteractor();
     $interactor->setResponseFactory(new SlackResponseFactory());
     $commander = new Commander($_ENV['SLACK_KEY'], $interactor);
     $response = $commander->execute('channels.list');
     $responseBody = $response->getBody();
     if (!$responseBody or !$responseBody['ok']) {
         throw new Exception('Sth Error Happened!');
     }
     foreach ($responseBody['channels'] as $chan) {
         if (!$chan['is_channel']) {
             continue;
         }
         $chanData = ['sid' => $chan['id'], 'name' => $chan['name'], 'created' => $chan['created'], 'creator' => $chan['creator'], 'purpose' => (object) $chan['purpose'], 'is_archived' => $chan['is_archived'], 'is_member' => $chan['is_member'], 'num_members' => $chan['num_members'], 'members' => $chan['members'], 'topic' => (object) $chan['topic']];
         if ($channel = Channel::where('sid', $chan['id'])->first()) {
             foreach ($chanData as $k => $v) {
                 $channel->{$k} = $v;
             }
             $channel->save();
         } else {
             $chanData['latest'] = 0;
             Channel::create($chanData);
         }
     }
 }
开发者ID:kenyiu,项目名称:slacklogs,代码行数:32,代码来源:LoadChannelsCommand.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $interactor = new CurlInteractor();
     $interactor->setResponseFactory(new SlackResponseFactory());
     $commander = new Commander($_ENV['SLACK_KEY'], $interactor);
     $channels = Channel::where('is_member', true)->get();
     foreach ($channels as $channel) {
         $latest = $channel->latest ?: 0;
         do {
             $response = $commander->execute('channels.history', ['channel' => $channel->sid, 'oldest' => $latest, 'count' => 1000]);
             $responseBody = $response->getBody();
             foreach ($responseBody['messages'] as $msg) {
                 $latest = $msg['ts'] > $latest ? $msg['ts'] : $latest;
                 $message = new Message();
                 foreach ($msg as $k => $v) {
                     $message->{$k} = is_string($v) ? $v : (object) $v;
                 }
                 $message->channel = $channel->sid;
                 $message->save();
             }
         } while ($responseBody['has_more']);
         $channel->latest = $latest;
         $channel->save();
     }
 }
开发者ID:kenyiu,项目名称:slacklogs,代码行数:31,代码来源:LoadMessagesCommand.php

示例3: infinite

 public function infinite($chan, $direction, $id)
 {
     $channel = Channel::where('name', $chan)->firstOrFail();
     $log = Message::findOrFail($id);
     // Build the query to fetch logs with
     if ($direction === 'up') {
         $logs = Message::where('channel', $channel->sid)->where('ts', '<', "{$log->ts}")->orderBy('ts', 'desc')->take($this->ajaxLoad)->get();
     } else {
         $logs = Message::where('channel', $channel->sid)->where('ts', '>', "{$log->ts}")->orderBy('ts', 'asc')->take($this->ajaxLoad)->get();
     }
     $logs = Message\Repository::convertCollection($logs);
     $loadMore = null;
     if (count($logs) === $this->ajaxLoad) {
         $loadMore = end($logs)->_id;
     }
     if ($direction === 'up') {
         $logs = array_reverse($logs);
     }
     return View::make('partials.logs', compact('chan', 'logs'))->with('more' . $direction, $loadMore);
 }
开发者ID:kenyiu,项目名称:slacklogs,代码行数:20,代码来源:LogsController.php

示例4: parseText

 public static function parseText($text)
 {
     preg_match_all('/<(.*?)>/', $text, $matches, PREG_SET_ORDER);
     if (!count($matches)) {
         return $text;
     }
     $fromText = [];
     $toText = [];
     foreach ($matches as $match) {
         // User link case
         if (preg_match('/^@U/', $match[1])) {
             list($uid, ) = explode("|", $match[1]);
             $fromText[] = $match[0];
             //if uid non-existent at db, return original uid.
             $username = ($select = User::where('sid', substr($uid, 1))->first()) == null ? "{$uid}" : $select->name;
             $toText[] = $username == '@USLACKBOT' ? '@slackbot' : $username;
             continue;
         }
         if (preg_match('/^#C/', $match[1])) {
             list($cid, ) = explode("|", $match[1]);
             $fromText[] = $match[0];
             $toText[] = '#' . Channel::where('sid', substr($cid, 1))->first()->name;
             continue;
         }
         if (preg_match('/^http/i', $match[1])) {
             list($url, ) = explode("|", $match[1]);
             $fromText[] = $match[0];
             $toText[] = $url;
             continue;
         }
     }
     if (count($fromText)) {
         $text = str_replace($fromText, $toText, $text);
     }
     return $text;
 }
开发者ID:kenyiu,项目名称:slacklogs,代码行数:36,代码来源:Helpers.php


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