<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use Yajra\Datatables\Datatables;

class UsersController extends Controller
{
    //
    public function index(){
        // $user = DB::table('t_users')->get();
        return view('admin.UsersList');
    }

    public function load(){
        DB::statement(DB::raw('set @rownum=0'));
		$d_data = DB::table('t_users')->get();

		return Datatables::of($d_data)
				->addColumn('aksi', function($d_data){
					$btnAction = '<button class="btn bg-warning-400" onclick="edit_kel('.$d_data->id.')"><i class="icon-pencil"></i> </button>
	 					<button class="btn bg-danger-800" type="button" onclick="hapus_kel('.$d_data->id.')"><i class="icon-eraser"></i></button>'.
						'<input type="hidden" id="table_id'.$d_data->id.'" value="'.$d_data->id.'">'.
						'<input type="hidden" id="table_user'.$d_data->id.'" value="'.$d_data->username.'">'.
						'<input type="hidden" id="table_pass'.$d_data->id.'" value="'.$d_data->password.'">';
					return $btnAction;
				})->make(true);
    }
}
