Last active
July 24, 2017 08:34
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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