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


PHP Collection::isEmpty方法代码示例

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


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

示例1: handle

 /**
  * Execute the job.
  *
  * @param Client $api Pre-configured instance of the Client
  */
 public function handle(Client $api)
 {
     // Initialize
     $this->api = $api;
     $this->api->setDefaultToken($this->token);
     $this->api->setPassError(config('vk-requester.pass_error', true));
     // Processing
     if (!$this->requests->isEmpty()) {
         $this->sendToApi();
         $this->fireEvents();
     }
 }
开发者ID:atehnix,项目名称:laravel-vk-requester,代码行数:17,代码来源:SendBatch.php

示例2: insertAllRow

 protected function insertAllRow($sheet)
 {
     $sheet->each(function ($row) {
         $data = $this->parseFilm($row);
         $data['genre_id'] = $this->findGenreId($row['genero'], $data['title']);
         $film = $this->film->create($data);
         $country_id = $this->findCountryId($row['pais'], $film);
         $film->countries()->sync($country_id);
     });
     if (!$this->newGenres->isEmpty()) {
         $this->info(Lang::get('commands.iffe.new-genres-added'));
         $this->info(implode(',', $this->newGenres->toArray()));
     }
 }
开发者ID:filmoteca,项目名称:filmoteca,代码行数:14,代码来源:ImportFilmsFromExcelCommand.php

示例3: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $month = new Carbon($this->argument('month'));
     $billboards = Billboard::activated()->get();
     $pictures = Storage::files();
     $missing_pictures = new Collection();
     foreach ($billboards as $billboard) {
         $facings = $billboard->facings->all();
         foreach ($facings as $facing) {
             $ref = $this->reference($billboard, $facing, $month);
             $image_url = "{$ref}.jpg";
             if (in_array($image_url, $pictures)) {
                 try {
                     $this->trackingRepository->create(['facing_id' => $facing->id, 'image_url' => $image_url, 'tracking_date' => $month, 'location_id' => $billboard->location_id]);
                     $this->info('Tracking #' . $ref . ' with image url ' . $image_url . ' created successfully.');
                 } catch (\Illuminate\Database\QueryException $e) {
                     $this->error('Tracking #' . $ref . ' already exists.');
                 }
             } else {
                 $this->error('Facing #' . $ref . ' picture missing.');
                 $missing_pictures->push(["name" => $facing->name, "image_url" => $image_url]);
             }
         }
     }
     if (!$missing_pictures->isEmpty()) {
         $this->notifyMissingPictures($missing_pictures, "it@sagaciresearch.com");
     }
 }
开发者ID:sagaciresearch,项目名称:adtracking,代码行数:33,代码来源:GenerateTrackings.php

示例4: formatEloquentCollection

 /**
  * Format an Eloquent collection.
  *
  * @param  \Illuminate\Database\Eloquent\Collection  $collection
  * @return string
  */
 public function formatEloquentCollection($collection)
 {
     if ($collection->isEmpty()) {
         return $this->encode([]);
     }
     $key = str_plural($collection->first()->getTable());
     return $this->encode([$key => $collection->toArray()]);
 }
开发者ID:andymrussell,项目名称:api,代码行数:14,代码来源:JsonResponseFormat.php

示例5: getCurrentStatus

 /**
  * Get the current status of the xml files according to the organization's segmentation/publishing type.
  * @param $currentFiles
  * @return array
  */
 public function getCurrentStatus(Collection $currentFiles)
 {
     $currentStatus = [];
     if (!$currentFiles->isEmpty()) {
         $currentFiles->each(function ($file) use(&$currentStatus) {
             $currentStatus[$file->filename]['included_activities'] = $file->extractActivityId();
             $currentStatus[$file->filename]['published_status'] = $file->published_to_register;
         });
     }
     return $currentStatus;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:16,代码来源:OrganizationDataProvider.php

示例6: format

 /**
  * Format data for simple csv
  * @param Collection $activities
  * @return array
  */
 public function format(Collection $activities)
 {
     if ($activities->isEmpty()) {
         return false;
     }
     $this->csvData = ['headers' => $this->headers];
     foreach ($activities as $activity) {
         $this->csvData[] = ['iati-identifier' => $activity->identifier['iati_identifier_text'], 'title' => !$activity->title ? '' : $this->formatTitle($activity->title), 'description_general' => !$activity->description ? '' : $this->formatDescription($activity->description, '1'), 'description_objective' => !$activity->description ? '' : $this->formatDescription($activity->description, '2'), 'description_target' => !$activity->description ? '' : $this->formatDescription($activity->description, '3'), 'description_others' => !$activity->description ? '' : $this->formatDescription($activity->description, '4'), 'activity-status' => (int) $activity->activity_status, 'start-planned' => !$activity->activity_date ? '' : $this->formatActivityDate($activity->activity_date, '1'), 'start-actual' => !$activity->activity_date ? '' : $this->formatActivityDate($activity->activity_date, '2'), 'end-planned' => !$activity->activity_date ? '' : $this->formatActivityDate($activity->activity_date, '3'), 'end-actual' => !$activity->activity_date ? '' : $this->formatActivityDate($activity->activity_date, '4'), 'funding_organisations' => !$activity->participating_organization ? '' : $this->formatParticipatingOrg($activity->participating_organization, '1'), 'accountable_organisations' => !$activity->participating_organization ? '' : $this->formatParticipatingOrg($activity->participating_organization, '2'), 'extending_organisations' => !$activity->participating_organization ? '' : $this->formatParticipatingOrg($activity->participating_organization, '3'), 'implementing_organisations' => !$activity->participating_organization ? '' : $this->formatParticipatingOrg($activity->participating_organization, '4'), 'recipient-country' => !$activity->recipient_country ? '' : $this->formatRecipientCountry($activity->recipient_country), 'recipient-country-codes' => !$activity->recipient_country ? '' : $this->formatRecipientCountryCodes($activity->recipient_country), 'recipient-country-percentages' => !$activity->recipient_country ? '' : $this->formatRecipientCountryPercentages($activity->recipient_country), 'recipient-region' => !$activity->recipient_region ? '' : $this->formatRecipientRegions($activity->recipient_region), 'recipient-region-codes' => !$activity->recipient_region ? '' : $this->formatRecipientRegionCodes($activity->recipient_region), 'recipient-region-percentages' => !$activity->recipient_region ? '' : $this->formatRecipientRegionPercentages($activity->recipient_region), 'sector-text' => !$activity->sector ? '' : $this->formatSectorText($activity->sector), 'sector-vocabularies' => !$activity->sector ? '' : $this->formatSectorVocabularies($activity->sector), 'sector-codes' => !$activity->sector ? '' : $this->formatSectorCodes($activity->sector), 'sector-percentages' => !$activity->sector ? '' : $this->formatSectorPercentages($activity->sector), 'total-incoming-funds' => !$activity->transactions ? '' : $this->formatTransactionValues($activity->transactions, 1), 'total-commitments' => !$activity->transactions ? '' : $this->formatTransactionValues($activity->transactions, 2), 'total-disbursements' => !$activity->transactions ? '' : $this->formatTransactionValues($activity->transactions, 3), 'total-expenditure' => !$activity->transactions ? '' : $this->formatTransactionValues($activity->transactions, 4)];
     }
     return $this->csvData;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:16,代码来源:SimpleCsvDataFormatter.php

示例7: formatEloquentCollection

 /**
  * Format an Eloquent collection.
  *
  * @param \Illuminate\Database\Eloquent\Collection $collection
  *
  * @return string
  */
 public function formatEloquentCollection($collection)
 {
     if ($collection->isEmpty()) {
         return $this->encode([]);
     }
     $model = $collection->first();
     $key = str_plural($model->getTable());
     if (!$model::$snakeAttributes) {
         $key = camel_case($key);
     }
     return $this->encode([$key => $collection->toArray()]);
 }
开发者ID:joselfonseca,项目名称:api,代码行数:19,代码来源:Json.php

示例8: format

 /**
  * Format data for Complete Csv generation.
  * @param Collection $activities
  * @return array
  */
 public function format(Collection $activities)
 {
     try {
         if ($activities->isEmpty()) {
             return false;
         }
         $this->prepareCsv($activities);
         $elementFactories = $this->generateElementFactories(array_keys(array_first($this->data, function ($index, $value) {
             return $value;
         })), $this->except);
         return $this->fillActivityElementData($elementFactories, $activities)->fillTransactionData($activities)->fillResultData($activities);
     } catch (Exception $exception) {
         $this->logger->error($exception);
     }
     return null;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:CompleteCsvDataFormatter.php

示例9: showProspects

 /**
  * Display one or more prospects.
  *
  * @note We're using the 'table()' function which expects an array
  *       of arrays (i.e. rows of data items/fields)
  *
  * @param Collection $prospects
  * @param bool $forceList
  * @param int $maxLen
  */
 protected function showProspects($prospects, $forceList = false, $maxLen = 76)
 {
     if (empty($prospects) || $prospects->isEmpty()) {
         $this->info('No prospect records to display');
         return;
     }
     if ($prospects->count() > 1 || $forceList) {
         $rows = $prospects->toArray();
         $this->table(array_keys($rows[0]), $rows);
     } else {
         $prospect = $prospects->first();
         $data = $prospect->toArray();
         $rows = [];
         foreach ($data as $k => $v) {
             $rows[] = [$k, is_string($v) ? str_limit($v, $maxLen) : $v];
         }
         $this->table(['field', 'value'], $rows);
     }
     $this->info('');
     // Print a blank line
 }
开发者ID:mlanser,项目名称:prospect-mgr,代码行数:31,代码来源:ProspectCommandTrait.php

示例10: createWrappersInCollection

 /**
  * to create a lot of wrapper by using models in Eloquent Collection
  * 
  * @param \Illuminate\Support\Collection $collection
  * @param \Illuminate\Database\Eloquent\Model|int $wantedLang language id or specific language model
  * @param \Illuminate\Database\Eloquent\Model|int $defaultLang language id or specific language model
  * @return \Illuminate\Support\Collection
  */
 protected function createWrappersInCollection(Collection $collection, $wantedLang, $defaultLang)
 {
     $newCollection = new EloquentColl();
     $tempCollection = new EloquentColl($collection->all());
     while (!$tempCollection->isEmpty()) {
         $newCollection->add($this->wrapper->createNew($tempCollection->shift(), $wantedLang, $defaultLang));
     }
     return $newCollection;
 }
开发者ID:muratsplat,项目名称:multilang,代码行数:17,代码来源:MultiLang.php


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