本文整理汇总了PHP中Illuminate\Support\Collection::implode方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::implode方法的具体用法?PHP Collection::implode怎么用?PHP Collection::implode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::implode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeDistributedName
protected function makeDistributedName()
{
$this->md5FileName = md5($this->getModel()->path . microtime(true)) . '.' . collect(explode('.', $this->getModel()->path))->last();
$this->getModel()->old_name = $this->getModel()->path;
$this->distributedPathCollection = collect([mb_substr($this->md5FileName, 0, 3), mb_substr($this->md5FileName, 3, 3), mb_substr($this->md5FileName, 6, 3)]);
$this->getModel()->name = mb_substr($this->md5FileName, 9);
$this->getModel()->distributed_path = $this->distributedPathCollection->implode($this->pathSeparator);
$this->getModel()->path = $this->getModel()->distributed_path . $this->pathSeparator . $this->getModel()->name;
return $this;
}
示例2: getCreatorsBatch
public function getCreatorsBatch(Collection $channelIds)
{
$ids = $channelIds->implode(',');
$params = ['id' => $ids, 'maxResults' => 50];
$result = $this->source->getCreator($params);
return Channel::createData(collect($result['items']));
}
示例3: lookup
/**
* Get the account details of up to 100 users
*
* @param Collection $usernames
* @return Collection
*/
public function lookup(Collection $usernames)
{
$response = $this->client->get('users/lookup.json', ['query' => 'screen_name=' . $usernames->implode(','), 'http_errors' => false]);
if ($response->getStatusCode() == Response::HTTP_NOT_FOUND) {
return new Collection();
}
return new Collection(json_decode($response->getBody()));
}
示例4: getVideosBatch
public function getVideosBatch(Collection $videoIds, $cacheKey, $force = false)
{
$videoIdsString = $videoIds->implode(',');
$params = ['maxResults' => 50, 'id' => $videoIdsString];
if ($force === true) {
Cache::forget($cacheKey);
}
$results = Cache::rememberForever($cacheKey, function () use($params) {
return $this->source->getVideo($params);
});
return Video::createData(collect($results['items']));
}
示例5: implode
/**
*
* 集合元素 转换成 字符串
*
* implode
*
*/
public function implode()
{
$val = $this->collection->map(function ($val, $key) {
return $val['price'];
});
debug($val);
//Desk,Chair,Bookcase,Door
$implode = $this->collection->implode('product', ',');
debug($implode);
//1-2-3-4-5
$implode = collect([1, 2, 3, 4, 5])->implode('-');
debug($implode);
return view('index');
}
示例6: testImplode
public function testImplode()
{
$data = new Collection([['name' => 'taylor', 'email' => 'foo'], ['name' => 'dayle', 'email' => 'bar']]);
$this->assertEquals('foobar', $data->implode('email'));
$this->assertEquals('foo,bar', $data->implode('email', ','));
$data = new Collection(['taylor', 'dayle']);
$this->assertEquals('taylordayle', $data->implode(''));
$this->assertEquals('taylor,dayle', $data->implode(','));
}
示例7: request
/**
* Requests the abstract request. But before it does so, it sets a few properties
* on the request like the extended level, page and it's limit
*
* @param AbstractRequest $request
* @return mixed
* @throws \Wubs\Trakt\Request\Exception\HttpCodeException\RateLimitExceededException
* @throws \Wubs\Trakt\Request\Exception\HttpCodeException\ServerErrorException
* @throws \Wubs\Trakt\Request\Exception\HttpCodeException\ServerUnavailableException
* @throws \Wubs\Trakt\Request\Exception\HttpCodeException\StatusCodeException
*/
protected function request(AbstractRequest $request)
{
return $request->setExtended($this->extended->implode(','))->setPage($this->page)->setLimit($this->limit)->make($this->clientId, $this->client);
}
示例8: addProperties
private function addProperties(Collection $properties)
{
$formatted = new Collection();
$properties->each(function ($property) use($formatted) {
$generator = new Property($this->apiNamespace . "\\" . $this->endpoint->implode("\\") . "\\" . $property, $this->filesystem);
$formatted->push($generator->generate());
});
return $this->writeInTemplate('public_properties', "\n" . $formatted->implode("\n\n"));
}