Mam taki problem mam obiekt
$qustions = new \App\User;
I w zależności od warunków które są spełnione chciałbym wywołać tylko określone operacje
Tutaj daje kod
$qustions = new \App\User;
if ($name != "") {
$qustions .= $this->where("name","like",$name);
}
if ($last_name != "") {
$qustions .= $this->where("last_name","like",$name);
}
if ($age_from != "") {
$qustions .= select(DB::raw("TIMESTAMPDIFF(YEAR, date_born, CURDATE()) as age "))->groupBy('age')->having("age",">=",$age_from);
}
if ($age_to != "") {
$qustions .= $this->select(DB::raw("TIMESTAMPDIFF(YEAR, date_born, CURDATE()) as age "))->groupBy('age')->having("age","<=",$age_to);
}
if ($city != "") {
$qustions .= $this->where("city","like",$name);
}
if ($voivodeship != "") {
$qustions .= $this->where("voivodeship","like",$name);
}
return $qustions->get();
I teraz chciałbym uzyskac taki efekt, że po spełnieniu określonych warunków lub nie w zmiennej utworzyła by się następująca instrukcja
$qustions->where('pole',1)->where("pole2",2) ja to zrobić.