Skip to content

Commit

Permalink
Chaging parseIncludes to now accept includes from the header or the q…
Browse files Browse the repository at this point in the history
…uery string.
  • Loading branch information
joshforbes committed Jan 31, 2016
1 parent 0a56af9 commit 131f6e3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,25 @@ public function __construct()
{
$this->fractal = App::make(Fractal::class);

$this->parseIncludes();
}

/**
* Parses includes from either the header or query string.
*
* @return mixed
*/
protected function parseIncludes()
{
if (Input::header('include')) {
return $this->fractal->parseIncludes(Input::header('include'));
}

if (Input::get('include')) {
$this->fractal->parseIncludes(Input::get('include'));
return $this->fractal->parseIncludes(Input::get('include'));
}

return null;
}

/**
Expand Down
14 changes: 13 additions & 1 deletion tests/Integration/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ public function setUp()
/**
* @test
*/
public function it_can_be_instantiated()
public function it_can_be_instantiated_with_header_includes()
{
request()->headers->add(['include' => 'test']);

$controller = new TestController();

$this->assertTrue(isset($controller));
}

/**
* @test
*/
public function it_can_be_instantiated_with_query_string_includes()
{
request()->query->add(['include' => 'test']);

Expand Down

0 comments on commit 131f6e3

Please sign in to comment.