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


PHP Collection::make方法代码示例

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


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

示例1: __construct

 /**
  * QueryFilter constructor.
  *
  * @param InputParser $parser
  * @param Collection $collection
  * @param Container $app
  */
 public function __construct(InputParser $parser, Collection $collection, Container $app)
 {
     $this->parser = $parser;
     $this->collection = $collection;
     $this->filters = $parser->getFilters();
     $this->sorts = $parser->getSorts();
     $this->appliedFilters = $collection->make();
     $this->appliedSorts = $collection->make();
     $this->app = $app;
 }
开发者ID:mnabialek,项目名称:laravel-eloquent-filter,代码行数:17,代码来源:QueryFilter.php

示例2: isVulnerable

 /**
  * @param      $vulnerabilities
  * @param      $version
  * @param null $found_vulnerabilities
  *
  * @return bool
  */
 public function isVulnerable($vulnerabilities, $version, &$found_vulnerabilities = null)
 {
     $found_vulnerabilities = Collection::make($vulnerabilities)->filter(function ($v) use($version) {
         return $this->semver->lessThan($version, $v->fixed_in);
     });
     return $found_vulnerabilities->count() > 0;
 }
开发者ID:Zae,项目名称:wp-vulnerabilities,代码行数:14,代码来源:VulnDBService.php

示例3: files

 /**
  * Array of language files grouped by file name.
  *
  * ex: ['user' => ['en' => 'user.php', 'nl' => 'user.php']]
  *
  * @return array
  */
 public function files()
 {
     $files = Collection::make($this->disk->allFiles($this->path));
     $filesByFile = $files->groupBy(function ($file) {
         $fileName = $file->getBasename('.' . $file->getExtension());
         if (Str::contains($file->getPath(), 'vendor')) {
             $fileName = str_replace('.php', '', $file->getFileName());
             $packageName = basename(dirname($file->getPath()));
             return "{$packageName}::{$fileName}";
         } else {
             return $fileName;
         }
     })->map(function ($files) {
         return $files->keyBy(function ($file) {
             return basename($file->getPath());
         })->map(function ($file) {
             return $file->getRealPath();
         });
     });
     // If the path does not contain "vendor" then we're looking at the
     // main language files of the application, in this case we will
     // neglect all vendor files.
     if (!Str::contains($this->path, 'vendor')) {
         $filesByFile = $this->neglectVendorFiles($filesByFile);
     }
     return $filesByFile;
 }
开发者ID:themsaid,项目名称:laravel-langman,代码行数:34,代码来源:Manager.php

示例4: collectModels

 /**
  * Get the results as a collection of model instances.
  *
  * @return Collection
  */
 protected function collectModels()
 {
     $modelClass = get_class($this->model);
     return Collection::make($this->query())->map(function ($result) use($modelClass) {
         return new $modelClass($result);
     });
 }
开发者ID:aaemnnosttv,项目名称:silk,代码行数:12,代码来源:Builder.php

示例5: checkType

 protected static function checkType($types)
 {
     $types = Collection::make($types);
     if (!$types->contains(static::TYPE)) {
         throw new DomainException('Invalid contact type: ' . $types->implode(','));
     }
 }
开发者ID:loduis,项目名称:alegra-php,代码行数:7,代码来源:Typeable.php

示例6: store

 /**
  * Create order record.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function store()
 {
     try {
         \DB::beginTransaction();
         $items = Collection::make(\Input::get('items'));
         $order = new Order();
         // create the order
         $order->save();
         // Attach items to order
         $items->each(function ($item) use($order) {
             $order->addItem($item);
         });
         // Calculate commission & profit
         /** @var \Paxifi\Support\Commission\CalculatorInterface $calculator */
         $calculator = \App::make('Paxifi\\Support\\Commission\\CalculatorInterface');
         $calculator->setCommissionRate($order->OrderDriver()->getCommissionRate());
         $order->setCommission($calculator->calculateCommission($order));
         $order->setProfit($calculator->calculateProfit($order));
         // save order
         $order->save();
         \DB::commit();
         return $this->setStatusCode(201)->respondWithItem(Order::find($order->id));
     } catch (ModelNotFoundException $e) {
         return $this->errorWrongArgs('Invalid product id');
     } catch (\InvalidArgumentException $e) {
         return $this->errorWrongArgs($e->getMessage());
     } catch (\Exception $e) {
         return $this->errorInternalError();
     }
 }
开发者ID:xintang22,项目名称:Paxifi,代码行数:35,代码来源:OrderController.php

示例7: getModels

 public function getModels(array $models = [])
 {
     foreach ($models as &$model) {
         $model = $this->model->newFromQuery($model);
     }
     return Collection::make($models);
 }
开发者ID:expresser,项目名称:support,代码行数:7,代码来源:Builder.php

示例8: LengthAwarePaginator

 function length_aware_paginator($items, $perPage, $currentPage = null, array $options = [])
 {
     $currentPage = $currentPage ?: LengthAwarePaginator::resolveCurrentPage();
     $startIndex = $currentPage * $perPage - $perPage;
     $paginatedItems = Collection::make($items)->slice($startIndex, $perPage);
     return new LengthAwarePaginator($paginatedItems, $items->count(), $perPage, $currentPage, ['path' => LengthAwarePaginator::resolveCurrentPath()]);
 }
开发者ID:draperstudio,项目名称:support,代码行数:7,代码来源:Data.php

示例9: collection

 /**
  * @param Collection $collection
  * @return \Illuminate\Support\Collection
  */
 public function collection(Collection $collection)
 {
     $activities = $collection->map(function ($item) {
         return self::single(Collection::make($item));
     });
     return $activities;
 }
开发者ID:filmoteca,项目名称:filmoteca,代码行数:11,代码来源:ActivityFactory.php

示例10: __construct

 /**
  * @param array|Collection $data
  */
 public function __construct($data = [])
 {
     $this->data = $data;
     if (!$this->data instanceof Collection) {
         $this->data = Collection::make($this->data);
     }
 }
开发者ID:portonefive,项目名称:essentials,代码行数:10,代码来源:Dictionary.php

示例11: testModels

 public function testModels()
 {
     $this->search->shouldReceive('config->models')->with([1, 2, 3, 4, 5], ['limit' => 2, 'offset' => 3])->andReturn([[1, 2, 3, 4, 5], 5]);
     $this->assertEquals(Collection::make([1, 2, 3, 4, 5]), $this->runner->models('test', ['limit' => 2, 'offset' => 3]));
     $this->assertEquals(5, $this->runner->getCachedCount('test'));
     $this->assertEquals(0, $this->runner->getCachedCount('other test'));
 }
开发者ID:robvanbentem,项目名称:laravel-lucene-search,代码行数:7,代码来源:RunnerTest.php

示例12: getAuditoriums

 /**
  * Devuelve una lista de los distintas salas de la colección de
  * exhibiciones dada.
  *
  *
  * @param $exhibitions Lista de exhibiciones.
  * @return  Collection Lista de todas las distintas salas de las exhibiciones dadas.
  */
 public function getAuditoriums($exhibitions)
 {
     $auditoriums = $exhibitions->reduce(function ($accum, $exhibition) {
         return $accum->merge($exhibition->auditoriums);
     }, Collection::make([]));
     return $auditoriums;
 }
开发者ID:filmoteca,项目名称:filmoteca,代码行数:15,代码来源:ExhibitionsManager.php

示例13: setUp

 public function setUp()
 {
     $claims = ['sub' => new Subject(1), 'iss' => new Issuer('http://example.com'), 'exp' => new Expiration(time() + 3600), 'nbf' => new NotBefore(time()), 'iat' => new IssuedAt(time()), 'jti' => new JwtId('foo')];
     $this->validator = Mockery::mock('Tymon\\JWTAuth\\Validators\\PayloadValidator');
     $this->validator->shouldReceive('setRefreshFlow->check');
     $this->payload = new Payload(Collection::make($claims), $this->validator);
 }
开发者ID:levieraf,项目名称:jwt-auth,代码行数:7,代码来源:PayloadTest.php

示例14: getTemplateList

 /**
  * @return static
  */
 public function getTemplateList()
 {
     $templates = Collection::make();
     $templates->put('default::page.default', '默认模板');
     static::$dispatcher->fire(new GetTemplateList($templates));
     return $templates;
 }
开发者ID:darrengopower,项目名称:framework,代码行数:10,代码来源:Page.php

示例15: show_docket

 public function show_docket($id)
 {
     $delivery_history = DeliveryHistory::find($id);
     $input = unserialize($delivery_history->input);
     $quote = QuoteRequest::find($delivery_history->qr_id);
     $delivery_address = CustomerAddress::find($input['delivery_address']);
     // Create PDF
     $qtys = isset($input['number']) ? $input['number'] : '';
     if (isset($input['number'])) {
         // Quantities are not equal
         $collection = Collection::make($input['number']);
         $numbers = $collection->flip()->map(function () {
             return 0;
         });
         foreach ($collection as $item) {
             $numbers[$item] += 1;
         }
         $html = view('jobs.docket', compact('input', 'quote', 'delivery_address', 'qtys', 'numbers'));
     } else {
         // Quantities are equal
         $html = view('jobs.docket', compact('input', 'quote', 'delivery_address', 'qtys'));
     }
     $dompdf = PDF::loadHTML($html);
     return $dompdf->stream();
 }
开发者ID:AlexAustralia,项目名称:printflow,代码行数:25,代码来源:JobsController.php


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