Skip to content

Commit

Permalink
Let setData handles data transformation (#15137)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot authored and taylorotwell committed Aug 30, 2016
1 parent 5257569 commit 51a85f1
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Illuminate/Routing/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Illuminate\Routing;

use JsonSerializable;
use Illuminate\Support\Str;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\View\Factory as ViewFactory;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
Expand Down Expand Up @@ -74,26 +72,22 @@ public function view($view, $data = [], $status = 200, array $headers = [])
/**
* Return a new JSON response from the application.
*
* @param string|array $data
* @param mixed $data
* @param int $status
* @param array $headers
* @param int $options
* @return \Illuminate\Http\JsonResponse
*/
public function json($data = [], $status = 200, array $headers = [], $options = 0)
{
if ($data instanceof Arrayable && ! $data instanceof JsonSerializable) {
$data = $data->toArray();
}

return new JsonResponse($data, $status, $headers, $options);
}

/**
* Return a new JSONP response from the application.
*
* @param string $callback
* @param string|array $data
* @param mixed $data
* @param int $status
* @param array $headers
* @param int $options
Expand Down

0 comments on commit 51a85f1

Please sign in to comment.