/** * Type protection * * @param mixed $value */ public function prepend($value) { if ($this->isValidElement($value)) { parent::prepend($value); } else { $this->handleInvalidElement($value); } }
/** * @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); } }
/** * */ 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(); } }
/** * 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); }
/** * @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; }
/** * @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; }
protected function selectWrap(Collection $item) { return $item->prepend('<select class="ui dropdown">')->push('</select>'); }
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()); }
/** * 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'); }
/** * 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: '******'remote_id' => $status->user->id]); } else { $this->info('Updating user: '******'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!'); } } }
/** * @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()); }
/** * 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; }
public function prepend($value, $key = null) { $value = $this->validateItem($value); return parent::prepend($value, $key); }