示例#1
0
 public function postPesquisa()
 {
     $dados = Input::all();
     if (isset($dados["columns"])) {
         $columns = $dados["columns"];
     }
     if (isset($dados["order"])) {
         $order = $dados["order"];
         $order = $order[0];
         $orderIndex = intval($order["column"]);
     }
     if (isset($dados["search"])) {
         $search = $dados["search"];
     }
     $limit = intval($dados["length"]);
     $start = intval($dados["start"]);
     $recordsTotal = count(VariedadesModel::get());
     if ($limit == -1) {
         $limit = $recordsTotal;
     }
     $bebidas = VariedadesModel::select(DB::raw('SQL_CALC_FOUND_ROWS *'))->where("cod", $search["value"])->orWhere("nome", "LIKE", "%" . $search["value"] . "%")->orWhere("descricao", "LIKE", "%" . $search["value"] . "%")->select("cod", "nome", "foto_url", "deletada")->orderBy($columns[$orderIndex]["name"], $order["dir"])->take($limit)->skip($start)->get();
     $recordsFiltered = DB::select(DB::raw("SELECT FOUND_ROWS() AS total;"));
     $recordsFiltered = $recordsFiltered[0];
     $recordsFiltered = intval($recordsFiltered->total);
     $json = [];
     $json["draw"] = intval($dados["draw"]);
     $json["recordsTotal"] = $recordsTotal;
     $json["recordsFiltered"] = $recordsFiltered;
     $json["aaData"] = array();
     foreach ($bebidas->toArray() as $key => $value) {
         if ($value["deletada"] == 1) {
             continue;
         }
         if ($value["foto_url"] != null) {
             $img = "<img style='max-width: 50px; max-height: 50px;' src='" . $value["foto_url"] . "' alt='../" . $value["foto_url"] . "'/>";
             $value["foto_url"] = $img;
         } else {
             $value["foto_url"] = "<img style='max-width: 50px; max-height: 50px;' src='../img/noimage.png' />";
         }
         array_push($json["aaData"], array_values($value));
     }
     return json_encode($json);
 }
示例#2
0
 public function postPesquisa()
 {
     $dados = Input::all();
     if (isset($dados["columns"])) {
         $columns = $dados["columns"];
     }
     if (isset($dados["order"])) {
         $order = $dados["order"];
         $order = $order[0];
         $orderIndex = intval($order["column"]);
     }
     if (isset($dados["search"])) {
         $search = $dados["search"];
     }
     $limit = intval($dados["length"]);
     $start = intval($dados["start"]);
     $recordsTotal = count(VariedadesModel::get());
     if ($limit == -1) {
         $limit = $recordsTotal;
     }
     $variedade = VariedadesModel::select(DB::raw('SQL_CALC_FOUND_ROWS *'))->where("cod", $search["value"])->orWhere("nome", "LIKE", "%" . $search["value"] . "%")->orderBy($columns[$orderIndex]["name"], $order["dir"])->take($limit)->skip($start)->get();
     $recordsFiltered = DB::select(DB::raw("SELECT FOUND_ROWS() AS total;"));
     $recordsFiltered = $recordsFiltered[0];
     $recordsFiltered = intval($recordsFiltered->total);
     $json = [];
     $json["draw"] = intval($dados["draw"]);
     $json["recordsTotal"] = $recordsTotal;
     $json["recordsFiltered"] = $recordsFiltered;
     $json["aaData"] = array();
     foreach ($variedade->toArray() as $key => $value) {
         if ($value["deletada"] == 1) {
             continue;
         }
         array_push($json["aaData"], array_values($value));
     }
     return json_encode($json);
 }