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


PHP Collection::setMeta方法代码示例

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


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

示例1: transform

 /**
  * Manage and finalize the data transformation.
  *
  * @param  \League\Fractal\Resource\Item|\League\Fractal\Resource\Collection  $data
  * @param  int  $code
  * @param  array  $meta
  * @return \Illuminate\Http\JsonResponse
  */
 public function transform($data, $code = 200, $meta = [])
 {
     $data->setMeta($meta);
     $manager = new Manager();
     $manager->setSerializer(new DataArraySerializer());
     $response = $manager->createData($data)->toArray();
     return response()->json($response, 200, [], JSON_UNESCAPED_SLASHES);
 }
开发者ID:DoSomething,项目名称:gladiator,代码行数:16,代码来源:ApiController.php

示例2: getPagination

 /**
  * Create FractalCollection payload with pagination.
  *
  * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
  * @param null                                                  $transformer
  * @param string|null                                           $resourceKey
  * @return mixed
  */
 public function getPagination(LengthAwarePaginator $paginator, $transformer = null, $resourceKey = null)
 {
     // Append existing query parameter to pagination link
     // @see http://fractal.thephpleague.com/pagination/#including-existing-query-string-values-in-pagination-links
     $queryParams = array_diff_key($_GET, array_flip(['page']));
     foreach ($queryParams as $key => $value) {
         $paginator->addQuery($key, $value);
     }
     $collection = $paginator->getCollection();
     $resource = new FractalCollection($collection, $this->getTransformer($transformer), $this->getResourceKey($resourceKey));
     $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
     if ($meta = $this->getMeta()) {
         $resource->setMeta($meta);
         $this->meta = [];
     }
     if ($includes = $this->getIncludes()) {
         $this->fractal->parseIncludes($this->request->input('include'));
         $this->includes = null;
     }
     return $this->fractal->createData($resource)->toArray();
 }
开发者ID:Kristories,项目名称:fractal,代码行数:29,代码来源:Response.php


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