I am get data from model and then passed to transformer while get trasformer's be passed to with view page when the to printed using echo.the output will be come with header how to remove header
this is my code:
public function productView($sulg)
{
$productcount = Product::where('deletestatus','=',0)->where('slug','=',$sulg)->count();
if($productcount != 0 )
{
$productdata = Product::where('deletestatus','=',0)->where('slug','=',$sulg)->get();
$review_product_information = $this->response->withCollection($productdata, new ProductTransformer);
return view('frontview.productview')->with('productdata', $review_product_information);
}
else
{
return view('frontview.404');
}
}
and I got output like this:
HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: application/json Date: Fri, 25 Mar 2016 10:54:53 GMT {"data":[{"product_id":6,"name":"Saree","sku":"h5f6uadl","slug":"saree","description":"Blue Saree","special_price_mrp":"5600.00","regular_price":"8000.00","wsprice":"5500.00","quantity":50,"offer_percentage":"40%","min_pay_for_rp":null,"discount_for_pp":null,"pro_tax":"1","category_id":"6","product_images":[{"image_id":1}]}]}
When passing data to a view, you should use View::make
method, like that:
View::make("frontview.productview")->with('productdata', $review_product_information);
EDIT: i actually misunderstood your question i think What do you mean by "remove header"? you want to return json without "data" array?
In laravel you can return JSON without using views, just like that:
return($review_product_information)