Код: Выделить всё
$amount = Input::get('amount'); // First getting the age range from the input in html (name="amount").
$amount = str_replace(' ','',$amount); //remove the blank spaces between the ages value, if there's any.
$amount = explode('-',$amount); // is breaking the value 16-45, as 16 and 45, '-' being the breaking point. And finally turns the value into array.
// Getting the array value as index 0 and 1.
$min = $amount[0];
$max = $amount[1];
$user = $request->user();
$userSelect = Input::get('select_preferences');
$prefQuery = Profile::whereHas('expectations', function($query) use($userSelect) {
$query->whereIn('name', $userSelect); // First Query: compare the name column in expectations table with the user selection.
//now chain another query:
})->whereBetween('age', [$min,$max])
->with('user', 'expectations')->get();
Код: Выделить всё
Collection {#192 ▼
#items: []
}
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/36455162/getting-empty-collection-from-a-query[/url]
Мобильная версия