/** * Display a listing of the resource. * * @return Response */ public function index() { if (Auth::check() && Auth::user()->roles == 'admin') { $users = User::sorted()->paginate(20); $users = Table::create($users, ['id', 'firstname', 'name', 'email']); $users->addColumn('roles', 'Roles', function ($model) { if ($model->roles == 'admin') { $icon = "<i class='material-icons'>build</i>"; } else { $icon = "<i class='material-icons'>face</i>"; } return $icon; }); $users->addColumn('created_at', 'Depuis', function ($model) { return $model->created_at->format('d M Y - H:i'); }); $users->addColumn('id', 'Editer', function ($model) { $url = route('profile', ['id' => $model->id]); echo "<a href='{$url}'><i class='material-icons'>create</i></a>"; }); return view('users/index')->with('users', $users); } else { abort(403, 'Unauthorized action.'); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { /*$users = User::sorted()->paginate(20); $users = Table::create($users, ['id','firstname', 'name', 'email']); $users->addColumn('roles', 'Roles', function($model) { if($model->roles == 'admin'){ $icon = "<i class='material-icons'>build</i>"; } else { $icon = "<i class='material-icons'>face</i>"; } return $icon; }); $users->addColumn('created_at', 'Depuis', function($model) { return $model->created_at->format('d M Y - H:i'); }); $users->addColumn('id', 'Editer', function($model) { $url = route('profile', ['id' => $model->id]); echo "<a href='$url'><i class='material-icons'>create</i></a>"; });*/ $foods = Foods::sorted()->paginate(20); /*$foods = DB::table('foods') ->leftJoin('categories', 'categories.id', '=', 'foods.category_id') ->select('categories.name', 'foods.*') ->get();*/ // //->get(); //dd($foods); //->sorted()->paginate(20); $foods = Table::create($foods, ['id', 'name', 'category_id', 'weight', 'sugar']); return view('foods/index')->with('foods', $foods); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $rows = Module::all(); //$rows = Module::get()->sorted()->paginate(); $table = Table::create($rows); // Generate a Table based on these "rows" return view('importmodules.index', compact('table')); }
function searchUsers(Request $request) { $search = $request->input('search'); $rows = User::with('role')->where(function ($query) use($search) { $query->Where('name', 'like', '%' . $search . '%')->orWhere('last_name', 'like', '%' . $search . '%')->orWhere('email', '=', $search)->orWhere('second_name', 'like', '%' . $search . '%')->orWhere('second_last_name', 'like', '%' . $search . '%')->orWhere('identification', '=', $search); })->sorted()->paginate(10); $users = Table::create($rows, ['name' => 'Nombre', 'email' => 'Email']); $users->addColumn('role_id', 'Rol', function ($model) { return $model->role()->first()->name; }); $users->addColumn('id', 'Acciones', function ($model) { $id = $model->id; return '<a href="' . route('user', ['id' => $id]) . '"> ver </a>'; }); $roleName = $this->roleName; $routeSearch = 'searchUser'; $roles = Role::whereRaw('id in (1,2,4,5)')->get(); return view('back.users', compact('users', 'roleName', 'routeSearch', 'search', 'roles')); }