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


PHP Collection::isEmpty方法代码示例

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


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

示例1: getModules

 /**
  * Modules of installed or not installed.
  *
  * @param bool $installed
  *
  * @return \Illuminate\Support\Collection
  */
 public function getModules($installed = false)
 {
     if ($this->modules->isEmpty()) {
         if ($this->files->isDirectory($this->getModulePath()) && !empty($directories = $this->files->directories($this->getModulePath()))) {
             (new Collection($directories))->each(function ($directory) use($installed) {
                 if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                     $package = new Collection(json_decode($this->files->get($file), true));
                     if (Arr::get($package, 'type') == 'notadd-module' && ($name = Arr::get($package, 'name'))) {
                         $module = new Module($name);
                         $module->setAuthor(Arr::get($package, 'authors'));
                         $module->setDescription(Arr::get($package, 'description'));
                         if ($installed) {
                             $module->setInstalled($installed);
                         }
                         if ($entries = data_get($package, 'autoload.psr-4')) {
                             foreach ($entries as $namespace => $entry) {
                                 $module->setEntry($namespace . 'ModuleServiceProvider');
                             }
                         }
                         $this->modules->put($directory, $module);
                     }
                 }
             });
         }
     }
     return $this->modules;
 }
开发者ID:notadd,项目名称:framework,代码行数:34,代码来源:ModuleManager.php

示例2: getExtensions

 /**
  * Extension list.
  *
  * @return \Illuminate\Support\Collection
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function getExtensions()
 {
     if ($this->extensions->isEmpty()) {
         if ($this->files->isDirectory($this->getExtensionPath()) && !empty($vendors = $this->files->directories($this->getExtensionPath()))) {
             collect($vendors)->each(function ($vendor) {
                 if ($this->files->isDirectory($vendor) && !empty($directories = $this->files->directories($vendor))) {
                     collect($directories)->each(function ($directory) {
                         if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                             $package = new Collection(json_decode($this->files->get($file), true));
                             if (Arr::get($package, 'type') == 'notadd-extension' && ($name = Arr::get($package, 'name'))) {
                                 $extension = new Extension($name);
                                 $extension->setAuthor(Arr::get($package, 'authors'));
                                 $extension->setDescription(Arr::get($package, 'description'));
                                 if ($entries = data_get($package, 'autoload.psr-4')) {
                                     foreach ($entries as $namespace => $entry) {
                                         $extension->setEntry($namespace . 'Extension');
                                     }
                                 }
                                 $this->extensions->put($directory, $extension);
                             }
                         }
                     });
                 }
             });
         }
     }
     return $this->extensions;
 }
开发者ID:notadd,项目名称:framework,代码行数:34,代码来源:ExtensionManager.php

示例3: victor

 /**
  * Get the winner of the Round
  * @return bool|Player
  */
 public function victor()
 {
     if ($this->battles->isEmpty()) {
         return false;
     }
     return $this->battles->last()->victor();
 }
开发者ID:aaemnnosttv,项目名称:War.php,代码行数:11,代码来源:Round.php

示例4: getAllPermissions

 /**
  * @param GrantableInterface $grantable
  *
  * @return array
  */
 public function getAllPermissions(GrantableInterface $grantable)
 {
     if (is_null($this->permissions) || $this->permissions->isEmpty()) {
         $this->initialize($grantable);
     }
     $result = $this->permissions->all();
     array_filter($result, function ($item) {
         return $item;
     });
     return array_keys($result);
 }
开发者ID:ndrx-io,项目名称:elude,代码行数:16,代码来源:Manager.php

示例5: postProcess

 /**
  * Runs the result for retrieval calls to the repository
  * through postprocessing.
  *
  * @param Collection|Model|null $result the result of the query, ready for postprocessing
  * @return Model|Collection|null
  */
 public function postProcess($result)
 {
     // determine whether there is anything to process
     if (is_null($result) || is_a($result, Collection::class) && $result->isEmpty()) {
         return $result;
     }
     // check if there is anything to do process it through
     if ($this->postProcessors->isEmpty()) {
         return $result;
     }
     // for each Model, instantiate and apply the processors
     if (is_a($result, Collection::class)) {
         $result->transform(function ($model) {
             return $this->applyPostProcessorsToModel($model);
         });
     } elseif (is_a($result, AbstractPaginator::class)) {
         // result is paginate() result
         // do not apply postprocessing for now (how would we even do it?)
         return $result;
     } else {
         // result is a model
         $result = $this->applyPostProcessorsToModel($result);
     }
     return $result;
 }
开发者ID:czim,项目名称:laravel-repository,代码行数:32,代码来源:ExtendedPostProcessingRepository.php

示例6: apply

 /**
  * @param Collection $collection
  * @return Collection
  */
 public function apply(Collection $collection)
 {
     if (!$collection->isEmpty() && !empty($this->criteria)) {
         foreach ($this->criteria as $key => $parameters) {
             // Парамментры могут быть пустыми
             if (empty($parameters)) {
                 continue;
             }
             // Фильтруем значение
             $collection = $collection->filter(function ($value, $k) use($key, $parameters) {
                 foreach ($parameters as $param) {
                     // Получем опреатор в зависимости от ключа
                     $exp = $this->getSign($key);
                     /** @var Parameters $param*/
                     if (count($param->getAttributes()) === 2) {
                         $attributes = $param->getAttributes();
                         return eval('return $value->{head($attributes)}' . $exp . ' $value->{last($attributes)};');
                     } else {
                         if (count($param->getAttributes()) === 1 && !empty($param->getValue())) {
                             return eval('return $value->{head($param->getAttributes())} ' . $exp . ' $param->getValue();');
                         }
                     }
                 }
                 return false;
             });
         }
     }
     return $collection;
 }
开发者ID:ftob,项目名称:php-leaderboard-bundle,代码行数:33,代码来源:BaseCriteria.php

示例7: validate

 public function validate()
 {
     if ($this->row_orders->isEmpty()) {
         $this->errors->add("row_orders", L::t("There is no product in the cart."));
         return false;
     }
     return true;
 }
开发者ID:palmabit,项目名称:catalog,代码行数:8,代码来源:Order.php

示例8: determineBaseline

 private function determineBaseline()
 {
     $baselines = BaselineFile::account($this->account)->orderBy('path', 'asc')->get();
     //-- convert to File::class
     $this->baseline = BaselineFile::toFiles($baselines);
     if ($this->baseline->isEmpty() && !$this->first_scan) {
         $this->alert("**Probable Compromise**<br> Empty baseline table (ALL baseline files are missing or deleted)!");
     }
 }
开发者ID:joshwhatk,项目名称:super-scan,代码行数:9,代码来源:Scan.php

示例9: getFromIds

 public function getFromIds(Collection $idCollection, $method, $force = false)
 {
     if ($idCollection->isEmpty()) {
         return $idCollection;
     }
     return $idCollection->unique()->map(function ($item, $key) use($force, $method) {
         return call_user_func([$this, $method], $item, $force);
     });
 }
开发者ID:Gamespectre,项目名称:spectator-api,代码行数:9,代码来源:ApiService.php

示例10: collection

 /**
  * Bind a collection to a transformer and start building a response.
  *
  * @param \Illuminate\Support\Collection $collection
  * @param object                         $transformer
  * @param array                          $parameters
  * @param \Closure                       $after
  *
  * @return \Dingo\Api\Http\ResponseBuilder
  */
 public function collection(Collection $collection, $transformer, array $parameters = [], Closure $after = null)
 {
     if ($collection->isEmpty()) {
         $class = get_class($collection);
     } else {
         $class = get_class($collection->first());
     }
     $binding = $this->transformer->register($class, $transformer, $parameters, $after);
     return new ResponseBuilder($collection, $binding);
 }
开发者ID:jacobDaeHyung,项目名称:api,代码行数:20,代码来源:ResponseFactory.php

示例11: getPaymentTypes

 /**
  * @return \Illuminate\Support\Collection
  * @throws \Artem328\LaravelYandexKassa\Exceptions\YandexKassaNoPaymentTypesProvidedException
  */
 public function getPaymentTypes()
 {
     if ($this->paymentTypes === null) {
         $this->paymentTypes = collect(config('yandex_kassa.payment_types', []));
     }
     if ($this->paymentTypes->isEmpty()) {
         throw new YandexKassaNoPaymentTypesProvidedException();
     }
     return $this->paymentTypes;
 }
开发者ID:artem328,项目名称:laravel-yandex-kassa,代码行数:14,代码来源:YandexKassa.php

示例12: __get

 /**
  * Gets the current flash level
  * and message using accessor methods.
  * 
  * @param  string $attribute
  * @return string|null
  */
 public function __get($attribute)
 {
     if ($this->current->isEmpty()) {
         return null;
     }
     $getter = 'get' . $attribute;
     if (method_exists($this, $getter)) {
         return $this->{$getter}();
     }
     return null;
 }
开发者ID:lukebro,项目名称:flash,代码行数:18,代码来源:FlashFactory.php

示例13: getThemes

 /**
  * Themes of installed or not installed.
  *
  * @param bool $installed
  *
  * @return \Illuminate\Support\Collection
  */
 public function getThemes($installed = false)
 {
     if ($this->themes->isEmpty()) {
         if ($this->files->isDirectory($this->getThemePath()) && !empty($directories = $this->files->directories($this->getThemePath()))) {
             (new Collection($directories))->each(function ($directory) use($installed) {
                 if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                     $package = new Collection(json_decode($this->files->get($file), true));
                     if (Arr::get($package, 'type') == 'notadd-extension' && ($name = Arr::get($package, 'name'))) {
                         $module = new Theme($name, Arr::get($package, 'authors'), Arr::get($package, 'description'));
                         if ($installed) {
                             $module->setInstalled($installed);
                         }
                         $this->themes->put($directory, $module);
                     }
                 }
             });
         }
     }
     return $this->themes;
 }
开发者ID:notadd,项目名称:framework,代码行数:27,代码来源:ThemeManager.php

示例14: outputAssets

 /**
  * Output the collection assets
  * @param  \Illuminate\Support\Collection $collection
  * @param  string $type
  * @return string
  */
 public function outputAssets($collection, $type)
 {
     if (!$collection->isEmpty()) {
         $link = $this->determineLinkingAttribute($type);
         $output = array();
         foreach ($collection->all() as $name => $attr) {
             $output[$name] = $this->createAssetTag($type, $link, $attr);
         }
         return implode($output, '');
     }
 }
开发者ID:nathanburkett,项目名称:ecosystem,代码行数:17,代码来源:Ecosystem.php

示例15: table

 /**
  * Set the table name or get the table name.
  * @param $name string
  * @return $this|string
  */
 public function table($name = null)
 {
     if (!$name) {
         return $this->table;
     }
     $this->table = $name;
     if ($this->labels->isEmpty()) {
         $this->guessLabels($name);
     }
     return $this;
 }
开发者ID:breachofmind,项目名称:birdmin,代码行数:16,代码来源:ModelBlueprint.php


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