Skip to content

Instantly share code, notes, and snippets.

@the94air
Last active July 24, 2017 08:34
Show Gist options
  • Save the94air/dd95f503c613949573d4882da8e66b62 to your computer and use it in GitHub Desktop.
Save the94air/dd95f503c613949573d4882da8e66b62 to your computer and use it in GitHub Desktop.
How many record I should allow to show Datatable Without making my slowing my page load.
<?php
class ArticlesController extends Controller {
public function show()
{
$count = Article::count();
if($count < [?]) {
// return the normal http view.
// the datatable will handle the dirty work.
$articles = Article::pluck('id', 'title', 'updated_at', 'active');
return view('articles.show')->withArticles();
} else {
// return Datatable ajax view.
// Make your own api to send the table data to the view.
return view('articles.ajax-show');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment