*/ class CategoryController 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('role.agent'); SettingsController::language(); } /** * Indexing all Category. * * @param type Category $category * * @return Response */ public function index() { /* get the view of index of the catogorys with all attributes of category model */ try { return view('themes.default1.agent.kb.category.index'); } catch (Exception $e) { return redirect()->back()->with('fails', $e->getMessage()); } } /** * fetching category list in chumper datatables. * * @return type chumper datatable */ public function getData() { /* fetching chumper datatables */ return Datatable::collection(Category::All()) /* search column name */ ->searchColumns('name') /* order column name and description */ ->orderColumns('name', 'description') /* add column name */ ->addColumn('name', function ($model) { $string = strip_tags($model->name); return Str::limit($string, 20); }) /* add column Created */ ->addColumn('Created', function ($model) { $t = $model->created_at; return TicketController::usertimezone($t); }) /* add column Actions */ /* there are action buttons and modal popup to delete a data column */ ->addColumn('Actions', function ($model) { return ''.\Lang::get('lang.delete').' id.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').' '.\Lang::get('lang.view').'