本文整理汇总了PHP中Illuminate\Support\Collection::prepend方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::prepend方法的具体用法?PHP Collection::prepend怎么用?PHP Collection::prepend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::prepend方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepend
/**
* Type protection
*
* @param mixed $value
*/
public function prepend($value)
{
if ($this->isValidElement($value)) {
parent::prepend($value);
} else {
$this->handleInvalidElement($value);
}
}
示例2: getLoopParent
/**
* @param \Illuminate\Support\Collection $list
* @param \Notadd\Category\Models\Category|null $model
*/
public function getLoopParent(Collection &$list, CategoryModel $model = null)
{
if ($model === null) {
$model = $this->model;
}
if ($model->hasParent()) {
$parent = $model->getAttribute('parent');
$list->prepend($parent);
$this->getLoopParent($list, $parent);
}
}
示例3: appendLooseAttributes
/**
*
*/
private function appendLooseAttributes()
{
foreach ($this->tabs as $tab) {
if ($tab->getName() === 'Algemeen') {
$tab->setAttributes($tab->merge($this->attributes));
$this->attributes = new Collection();
}
}
if ($this->attributes->count()) {
$tab = new Tab('Algemeen');
$tab->setAttributes($this->attributes);
$this->tabs->prepend($tab);
$this->attributes = new Collection();
}
}
示例4: index
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$user = $request->user();
$follows = $user->followers();
$followers = $follows->get();
$followers->prepend($user);
$allTweets = new Collection();
foreach ($followers as $follower) {
$allTweets->prepend($follower->tweets);
}
$tweets = new Collection();
foreach ($allTweets as $tweet) {
foreach ($tweet as $key => $value) {
$tweets->prepend($value);
}
}
$tweets = $tweets->sortByDesc('created_at');
$homeData = array();
$homeData['tweets'] = $tweets;
$homeData['path_image'] = storage_path('photos');
return view('home', $homeData);
}
示例5: compile
/**
* @param CommandContextInterface $commandContext
* @return Collection
*/
protected function compile(CommandContextInterface $commandContext)
{
$this->logFile = storage_path('logs/async/' . (string) round(microtime(true) * 1000) . mt_rand(1, 10000) . '.log');
$memoryLimit = config('satis.memory_limit');
$buildVerbosity = config('satis.build_verbosity');
$chunks = new Collection(['php' . ($memoryLimit !== null ? ' -dmemory_limit=' . $memoryLimit : ''), sprintf($this->executable, DIRECTORY_SEPARATOR), $this->command . ($buildVerbosity !== null ? ' -' . $buildVerbosity : ''), $this->configPath, $this->buildDirectory]);
if ($this->item !== null) {
$chunks->push($this->item);
}
$chunks->push($commandContext->getOutputRedirection($this->logFile));
$chunks->push($commandContext->getShouldUnlockOnCompletion());
foreach (['http', 'https'] as $protocol) {
$proxy = $this->proxySettings->get($protocol);
if ($proxy !== null) {
$chunks->prepend(strtoupper($protocol) . '_PROXY=' . $proxy);
}
}
$chunks->reject(function ($commandChunk) {
return trim($commandChunk) === '';
});
return $chunks;
}
示例6: getPager
/**
* @param Page $pagerCurrentPage
* @return IlluminateCollection
*/
protected function getPager($pagerCurrentPage)
{
$pagerCurrentPage = $pagerCurrentPage->id ? $pagerCurrentPage : Page::sorted()->visible()->first();
$pager = new IlluminateCollection();
$pager->push($pagerCurrentPage);
// e.g. page 6
/** @var Collection $previousPages */
$previousPages = $pagerCurrentPage->previous(4)->visible()->with(['pageable', 'parent'])->get();
// 5 4 3 2
/** @var Collection $nextPages */
$nextPages = $pagerCurrentPage->next(4)->visible()->with(['pageable', 'parent'])->get();
// 7 8 9 10
do {
$prevPage = $previousPages->shift();
if ($prevPage) {
$pager->prepend($prevPage);
}
$nextPage = $nextPages->shift();
if ($nextPage) {
$pager->push($nextPage);
}
} while ($pager->count() < 5 && ($previousPages->count() > 0 || $nextPages->count() > 0));
return $pager;
}
示例7: selectWrap
protected function selectWrap(Collection $item)
{
return $item->prepend('<select class="ui dropdown">')->push('</select>');
}
示例8: testPrepend
public function testPrepend()
{
$c = new Collection(['one', 'two', 'three', 'four']);
$this->assertEquals(['zero', 'one', 'two', 'three', 'four'], $c->prepend('zero')->all());
$c = new Collection(['one' => 1, 'two' => 2]);
$this->assertEquals(['zero' => 0, 'one' => 1, 'two' => 2], $c->prepend(0, 'zero')->all());
}
示例9: isEnabled
/**
* Parse the status information from the stages file.
*
* @param \pandaac\Exporter\Contracts\Reader $reader
* @param \Illuminate\Support\Collection $collection
* @return \Illuminate\Support\Collection
*/
protected function isEnabled(Reader $reader, Collection $collection)
{
return $collection->prepend((bool) $reader->attribute('enabled'), 'enabled');
}
示例10: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (!count(Config::get('feeder.keywords'))) {
$this->info('There are no keywords set.');
} else {
$this->info('Searching for new tweets...');
$newest = Twitter::newest();
if (!count($newest->statuses)) {
$this->info('No new tweets were found.');
} else {
$refresh = new Collection();
$this->info('Adding new tweets...');
foreach ($newest->statuses as $status) {
if (!isset($status->user)) {
$this->error('There is no user associated with the tweet: ' . $status->id);
} else {
$user = $this->user->findBy('remote_id', $status->user->id);
if (!$user instanceof User) {
$this->info('Adding user: ' . $status->user->id);
$user = new User(['remote_id' => $status->user->id]);
} else {
$this->info('Updating user: ' . $user->remote_id);
}
$user->name = $status->user->name;
$user->screen_name = $status->user->screen_name;
$user->location = $status->user->location;
$user->description = $status->user->description;
$user->followers_count = $status->user->followers_count;
$user->friends_count = $status->user->friends_count;
$user->listed_count = $status->user->listed_count;
$user->favourites_count = $status->user->favourites_count;
$user->added_at = new MongoDate(strtotime($status->user->created_at));
$user->save();
$tweet = $this->tweet->findBy('remote_id', $status->id);
if (!$tweet instanceof Tweet) {
$this->info('Adding tweet: ' . $status->id);
$tweet = new Tweet(['remote_id' => $status->id]);
} else {
$this->info('Updating tweet: ' . $tweet->remote_id);
}
$tweet->text = $status->text;
$tweet->lang = $status->lang;
$tweet->retweet_count = $status->retweet_count;
$tweet->favorite_count = $status->favorite_count;
$tweet->tweeted_at = new MongoDate(strtotime($status->created_at));
$tweet->save();
$user->tweets()->save($tweet);
if (isset($status->entities->media) && count($status->entities->media)) {
foreach ($status->entities->media as $remoteMedia) {
$media = $this->media->findBy('remote_id', $remoteMedia->id);
if (!$media instanceof Media) {
$this->info('Adding media: ' . $remoteMedia->id);
$media = new Media(['remote_id' => $remoteMedia->id]);
} else {
$this->info('Updating media: ' . $media->remote_id);
}
$media->media_url = $remoteMedia->media_url;
$media->media_url_https = $remoteMedia->media_url_https;
$media->url = $remoteMedia->url;
$media->display_url = $remoteMedia->display_url;
$media->expanded_url = $remoteMedia->expanded_url;
$media->type = $remoteMedia->type;
$media->save();
if (isset($remoteMedia->sizes) && count($remoteMedia->sizes)) {
foreach ($remoteMedia->sizes as $size => $remoteSize) {
$media->sizes()->attach(new Size(['size' => $size, 'w' => $remoteSize->w, 'h' => $remoteSize->h, 'resize' => $remoteSize->resize]));
}
}
$tweet->media()->sync([$media->{$media->getKeyName()}], false);
$media->tweets()->sync([$user->{$user->getKeyName()}], false);
}
}
$refresh->prepend($tweet);
}
}
event(new TweetsWereRefreshed($refresh));
$this->info('Tweets were added successfully!');
}
}
}
示例11: prepend
/**
* @param PageInterface $page
* @param string|null $key
*
* @return $this
*/
public function prepend($page, $key = null)
{
if (!$page instanceof PageInterface) {
throw new \InvalidArgumentException('$page must be instance of PageInterface');
}
return parent::prepend($page, $page->getId());
}
示例12: details
/**
* Parse the detailed information from the monster file.
*
* @param \pandaac\Exporter\Contracts\Reader $reader
* @param \Illuminate\Support\Collection $collection
* @return \Illuminate\Support\Collection
*/
protected function details(Reader $reader, Collection $collection)
{
$attributes = $reader->attributes('name', 'nameDescription', 'race', 'experience', 'speed', 'manacost', 'skull');
foreach (array_reverse($attributes) as $attribute => $value) {
$collection->prepend($value, $attribute);
}
return $collection;
}
示例13: prepend
public function prepend($value, $key = null)
{
$value = $this->validateItem($value);
return parent::prepend($value, $key);
}