/**
  * Run the request filter.
  *
  * @param Request $request
  * @param Closure $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->has('include')) {
         $this->service->parseIncludes($request->get('include'));
     }
     return $next($request);
 }
Ejemplo n.º 2
0
 /**
  * Tests the Author include.
  */
 public function testAuthorInclude()
 {
     $this->service = new FractalService();
     $this->author = new Author('Test', 'Author');
     $this->book = new Book('Test Book', 'Test Publisher', $this->author);
     $this->transformer = new BookTransformer();
     $this->specify('The key "data" is required.', function () {
         $item = $this->service->item($this->book, $this->transformer)->toArray();
         verify($item)->hasKey('data');
     });
     $this->specify('Author last name must be "Author".', function () {
         $item = $this->service->item($this->book, $this->transformer)->toArray();
         verify($item['data']['author'])->hasKey('data');
         verify($item['data']['author']['data'])->hasKey('lastName');
         verify($item['data']['author']['data']['lastName'])->equals('Author');
     });
 }
 /**
  * @param FractalService $service
  * @param array          $config
  */
 protected function configureService(FractalService $service, array $config)
 {
     if (!empty($config['default_serializer'])) {
         $service->setDefaultSerializer(new $config['default_serializer']());
     }
 }