Response::make PHP Method

make() public static method

Return a new response from the application.
public static make ( string $content = '', integer $status = 200, array $headers = [] ) : Illuminate\Http\Response
$content string
$status integer
$headers array
return Illuminate\Http\Response
        public static function make($content = '', $status = 200, $headers = array())
        {
            return \Illuminate\Routing\ResponseFactory::make($content, $status, $headers);
        }

Usage Example

Example #1
0
 /**
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Use content negotiation to determine the correct format to return
     $negotiator = new \Negotiation\FormatNegotiator();
     $acceptHeader = Request::header('accept');
     // Set priorities to json (if the app requests json provide it in favor of html)
     $priorities = array('application/json', 'text/html', '*/*');
     // Get the best appropriate content type
     $result = $negotiator->getBest($acceptHeader, $priorities);
     // Default to html if $result is not set
     $val = "text/html";
     if (isset($result)) {
         $val = $result->getValue();
     }
     // See what kind of content we should return
     switch ($val) {
         case "text/html":
             // In case we want to return html, just let
             // Laravel render the view and send the headers
             return Response::view('route.planner')->header('Content-Type', "text/html")->header('Vary', 'accept');
             break;
         case "application/json":
         default:
             // In case we want to return JSON(LD) or something else, generate
             // our JSON by calling our static function 'getJSON()'
             return Response::make($this::getJSON())->header('Content-Type', "application/json")->header('Vary', 'accept');
             break;
     }
 }
All Usage Examples Of Response::make