Я намагаюся повернути результати пошуку в масив, щоб відображатися в blade, але отримувати помилку:
$persons = persons::where("name","like","%$search_term%")->lists("id");
foreach($persons as $person)
{
$trials = trial::with("samples")->with("persons")->where("persons_id", "=", $person)->get();
}
FatalErrorException in 0bfe77047992e2dce86ae561e266494c рядок 37: виклик до невизначеного методу IlluminateDatabaseEloquentCollection :: appends ()
Я намагаюся це з + масив, але отримати помилки
Відповіді:
2 для відповіді № 1Ви можете скористатись whereIn()
Метод конструктора запитів. Див документи.
$persons = Person::where("name", "like", "%$search_term%")->lists("id");
$trials = Trial::with("samples")->with("persons")->whereIn("person_id", $persons)->get();