Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // Paginate resource resutls
     $results = $this->paginate();
     // If results found add asset to make tables responsive
     $results->total();
     // Create header links for sorting by column
     $links = (object) link_to_sort_by($this->resource->getVisibleLabels());
     // Set the route for the return button
     $returnRouteName = replace_last_segment($this->prefix);
     // Add data to the view
     $view = view('resource.index', compact(['results', 'links', 'returnRouteName']));
     // Add data to the layout
     $this->layout->title = $this->resource->plural();
     $this->layout->subtitle = $results->lastPage() > 1 ? sprintf(_('Page %d/%d'), $results->currentPage(), $results->lastPage()) : _('Index');
     // Return layout + view
     return $this->layout($view);
 }