Render view without layout

Submitted by leoden - 9 years ago

I have some pages that I like to popup in an informative ajax modal as well as having their own page. However as those pages extend a layout within the template I was getting the whole page with layout in my modal. Using renderSections() was the solution. In the example below my template section was called 'content'

// In my ViewingTimesController
public function getTimesForSale(Request $request,Sale $sale)
{
    // Do some logic

    if($request->ajax()) {
         return view('viewing_times.view_times',compact('viewing_times','catalogue_sections'))->renderSections()['content'];
    }

    // return the standard full view
}