*/ class ArticleController extends Controller { /** * Create a new controller instance. * constructor to check * 1. authentication * 2. user roles * 3. roles must be agent. * * @return void */ public function __construct() { // checking authentication $this->middleware('auth'); // checking roles $this->middleware('roles'); SettingsController::language(); } public function test() { //$table = $this->setDatatable(); return view('themes.default1.agent.kb.article.test'); } /** * Fetching all the list of articles in a chumper datatable format. * * @return type void */ public function getData() { $article = new Article(); $articles = $article ->select('id', 'name', 'description', 'publish_time', 'slug') ->orderBy('publish_time', 'desc') ->get(); // returns chumper datatable return Datatable::Collection($articles) /* add column name */ ->addColumn('name', function ($model) { $name = Str::limit($model->name, 20, '...'); return "
name>$name
"; }) /* add column Created */ ->addColumn('publish_time', function ($model) { $t = $model->publish_time; return $t; }) /* add column action */ ->addColumn('Actions', function ($model) { /* here are all the action buttons and modal popup to delete articles with confirmations */ return ' '.\Lang::get('lang.delete').' '.\Lang::get('lang.edit').' '.\Lang::get('lang.view').'