public function index(ArticlesDataTable $dataTable)
    {
        $categories = [];
        $allYesNo   = [];
        $statuses   = [];

        if (! request()->wantsJson()) {
            $categories = Category::root()->getDescendants()->map(function(Category $category) {
                $category->title = $category->present()->name;
                return $category;
            })->pluck('title', 'id');
            $categories = collect(['' => '- Select Category -'])->union($categories);

            $allYesNo = [
                '' => '- Select Article Type -',
                0  => 'Article',
                1  => 'Page',
            ];

            $statuses = [
                '' => '- Select Status -',
                0  => 'Unpublished',
                1  => 'Published',
            ];
        }

        return $dataTable->render('administrator.articles.index', compact('categories', 'allYesNo', 'statuses'));
    }
public function index(ArticlesDataTable $dataTable)
    {
        $categories = [];
        $allYesNo   = [];
        $statuses   = [];

        if (! request()->wantsJson()) {
            $categories = Category::root()->getDescendants()->map(function(Category $category) {
                $category->title = $category->present()->name;
                return $category;
            })->pluck('title', 'id');
            $categories = collect(['' => '- Select Category -'])->union($categories);

            $allYesNo = [
                '' => '- Select Article Type -',
                0  => 'Article',
                1  => 'Page',
            ];

            $statuses = [
                '' => '- Select Status -',
                0  => 'Unpublished',
                1  => 'Published',
            ];
        }

        return $dataTable->render('administrator.articles.index', compact('categories', 'allYesNo', 'statuses'));
    }
public function index ( ArticlesDataTable $ dataTable ) { $ categories = [ ] ; $ allYesNo = [ ] ; $ statuses = [ ] ; if ( ! request ( ) -> wantsJson ( ) ) { $ categories = Category :: root ( ) -> getDescendants ( ) -> map ( function ( Category $ category ) { $ category -> title = $ category -> present ( ) -> name ; return $ category ; } ) -> pluck ( 'title' , 'id' ) ; $ categories = collect ( [ '' => '- Select Category -' ] ) -> union ( $ categories ) ; $ allYesNo = [ '' => '- Select Article Type -' , 0 => 'Article' , 1 => 'Page' , ] ; $ statuses = [ '' => '- Select Status -' , 0 => 'Unpublished' , 1 => 'Published' , ] ; } return $ dataTable -> render ( 'administrator.articles.index' , compact ( 'categories' , 'allYesNo' , 'statuses' ) ) ; }
Display list of articles.

@param \Yajra\CMS\DataTables\ArticlesDataTable $dataTable
@return \Illuminate\Http\JsonResponse|\Illuminate\View\View
Display list of articles .