diff --git a/app/DataTables/Articles3DataTable.php b/app/DataTables/ArticlesDataTable.php similarity index 75% rename from app/DataTables/Articles3DataTable.php rename to app/DataTables/ArticlesDataTable.php index b9dcb59..08cc9c7 100644 --- a/app/DataTables/Articles3DataTable.php +++ b/app/DataTables/ArticlesDataTable.php @@ -5,7 +5,7 @@ use App\Article; use Yajra\Datatables\Services\DataTable; -class Articles3DataTable extends DataTable +class ArticlesDataTable extends DataTable { /** * Display ajax response. @@ -18,6 +18,10 @@ public function ajax() ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view') ->make(true); + + // $articles = Article::select(['id', 'title', 'body', 'created_at', 'updated_at']); + // return Datatables::of($articles)->editColumn('title', '{{ $title."-title" }}')->make(); + } /** @@ -27,9 +31,12 @@ public function ajax() */ public function query() { - $query = Article::query(); + //$query = Article::query(); + $query = Article::query()->select(['id', 'title', 'created_at', 'updated_at']); - return $this->applyScopes($query); + //return $this->applyScopes($query); + + return $query; } /** @@ -56,6 +63,7 @@ protected function getColumns() return [ 'id', // add your columns + 'title', 'created_at', 'updated_at', ]; diff --git a/app/Http/Controllers/Article3Controller.php b/app/Http/Controllers/Article3Controller.php deleted file mode 100644 index 2869671..0000000 --- a/app/Http/Controllers/Article3Controller.php +++ /dev/null @@ -1,19 +0,0 @@ -render('articles2.index3'); - - - } - -} diff --git a/app/Http/Controllers/Articles2Controller.php b/app/Http/Controllers/Articles2Controller.php deleted file mode 100644 index 96388dc..0000000 --- a/app/Http/Controllers/Articles2Controller.php +++ /dev/null @@ -1,42 +0,0 @@ -middleware('auth'); - } - - /** - * Display a listing of the resource. - */ - public function index() { - return view('articles2.index'); - } - - /** - * Process datatables ajax request. - */ - public function anyData() { - //return Datatables::of(\App\Article::query())->make(true); - - // $articles = Article::select(['id', 'title', 'body', 'created_at', 'updated_at']); - - // return Datatables::of($articles)->editColumn('title', '{{ $title."-title" }}')->make(); - - - return Datatables::of(Article::query())->make(); - - } - - -} diff --git a/app/Http/Controllers/ArticlesDTController.php b/app/Http/Controllers/ArticlesDTController.php new file mode 100644 index 0000000..463f703 --- /dev/null +++ b/app/Http/Controllers/ArticlesDTController.php @@ -0,0 +1,50 @@ +middleware('auth'); + } + + /** + * Display a listing of the resource. + */ + public function index() { + return view('datatables.index'); + } + + /** + * Process datatables ajax request. + */ + public function getBasicData() { + + $articles = Article::select(['id', 'title', 'body', 'created_at', 'updated_at']); + return Datatables::of($articles)->make(); + + //return Datatables::of(Article::query())->make(); + } + + /** + * Process datatables ajax request. + */ + public function AddEditRemoveColumn() { + + $articles = Article::select(['id', 'title', 'body', 'created_at', 'updated_at']); + + return Datatables::of($articles)->addColumn('action', 'edit')->make(); + + //return Datatables::of(Article::query())->make(); + } + + +} diff --git a/app/Http/Controllers/ArticlesDTSController.php b/app/Http/Controllers/ArticlesDTSController.php new file mode 100644 index 0000000..85ee6fd --- /dev/null +++ b/app/Http/Controllers/ArticlesDTSController.php @@ -0,0 +1,19 @@ +render('datatables.index2'); + + + } + +} diff --git a/resources/views/articles2/index.blade.php b/resources/views/datatables/index.blade.php similarity index 64% rename from resources/views/articles2/index.blade.php rename to resources/views/datatables/index.blade.php index db8b47a..99d0516 100644 --- a/resources/views/articles2/index.blade.php +++ b/resources/views/datatables/index.blade.php @@ -7,7 +7,7 @@
Id | @@ -15,6 +15,7 @@Article Body | Created At | Updated At | +
---|