Skip to content

Instantly share code, notes, and snippets.

@the94air
Last active July 24, 2017 08:34
Show Gist options
  • Select an option

  • Save the94air/dd95f503c613949573d4882da8e66b62 to your computer and use it in GitHub Desktop.

Select an option

Save the94air/dd95f503c613949573d4882da8e66b62 to your computer and use it in GitHub Desktop.

Revisions

  1. the94air revised this gist Jul 24, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions ArticlesController.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ?>
    <?php

    class ArticlesController extends Controller {

    @@ -12,7 +12,7 @@ public function show()
    return view('articles.show')->withArticles();
    } else {
    // return Datatable ajax view.
    // use articles api to get the table data.
    // Make your own api to send the table data to the view.
    return view('articles.ajax-show');
    }
    }
  2. the94air created this gist Jul 24, 2017.
    20 changes: 20 additions & 0 deletions ArticlesController.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    ?>

    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.
    // use articles api to get the table data.
    return view('articles.ajax-show');
    }
    }

    }