У меня такая проблема при создании расширенного поиска, и теперь, как и в параметре поиска, я выберу суточную дозу, т.е. она выполнит условные инструкции $ Usee-> GroupBy ("date");Он получает сообщение
Цитата SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dat' in 'group statement' (SQL: select count(*) as aggregate from
пользователь left join
продукт on
продукт .
id =
пользователь .
id_products left join
forwarding_description on
пользователь .
id=
forwarding_descriptions .
id_usees left join
описание on
описание .
ID =
forwarding_descriptions .
id_descriptions where
usees * одна тысяча двадцать один * id_users * +1022 * продукты * один тысяча двадцать три * ID in (160) group by
DAT * тысяча двадцать пять*
Blockquote Так же, как если бы он вообще не делал все эти selectRaws, но, в свою очередь, если у него нет этой опции, дневная доза работает все хорошо и только не работает для paginate для get works и дляsimplepaginate также работает неправильно, давая код курса.
public function createQuestions($bool) {
$usee = usee::query();
$hour = $this->selectHourStart(Auth::User()->id);
$usee
->selectRaw("products.name as name")
->select( DB::Raw("(DATE(IF(HOUR(usees.date) >= $hour, usees.date,Date_add(usees.date, INTERVAL - 1 DAY) )) ) AS dat "))
->selectRaw("hour(usees.date) as hour")
->selectRaw("sum(usees.portion) as por")
->selectRaw("day(usees.date) as day")
->selectRaw("month(usees.date) as month")
->selectRaw("year(usees.date) as year")
->selectRaw("usees.portion as portion")
->selectRaw("usees.date as date")
->selectRaw("descriptions.description as description")
->selectRaw("descriptions.date as date_description")
->selectRaw("usees.id_products as product")
->leftjoin("products","products.id","usees.id_products")
->leftjoin("forwarding_descriptions","usees.id","forwarding_descriptions.id_usees")
->leftjoin("descriptions","descriptions.id","forwarding_descriptions.id_descriptions")
->where("usees.id_users",Auth::User()->id);
if (Input::get("data1") != "") {
$usee->where("usees.date",">=",Input::get("data1"));
}
if (Input::get("data2") != "") {
$usee->where("usees.date","<=",Input::get("data2"));
}
if (Input::get("dose1") != "" and Input::get("day") == "") {
$usee->where("usees.portion",">=",Input::get("dose1"));
}
if (Input::get("dose2") != "" and Input::get("day") == "") {
$usee->where("usees.portion","<=",Input::get("dose2"));
}
if (Input::get("search") != "") {
$usee->where("descriptions.description","like","%" . Input::get("search") . "%");
}
if (Input::get("inDay") != "") {
$usee->where("descriptions.description","!=", "");
}
if ($bool == true) {
$usee->whereIn("products.id",$this->id_product);
}
// chodzi o to if (Input :: get ("day")! = "") {
$usee->groupBy("dat");
if (Input::get("dose1") != "" ) {
$usee->havingRaw("sum(usees.portion) >= " . Input::get("dose1"));
}
if (Input::get("dose2") != "" ) {
$usee->havingRaw("sum(usees.portion) <= " . Input::get("dose2"));
}
}
else {
$usee->groupBy("usees.id");
}
$list = $usee->orderBy(Input::get("sort"),"DESC")->paginate(200);
//foreach ($list as $l) {
// print $l->name;
//}
return $list;
}