本文整理汇总了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);
}
}
}
示例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();
}
}
示例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);
}
示例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;
}