Получение пустой коллекции из запросаPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Получение пустой коллекции из запроса

Сообщение Anonymous »

У меня такой запрос:

Код: Выделить всё

$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();
Я пытаюсь получить выбор пользователя и возрастной диапазон. При запуске dump($prefQuery); - я получаю пустую коллекцию:

Код: Выделить всё

Collection {#192 ▼
#items: []
}
Вот запрашиваемая модель профиля:

Код: Выделить всё


Подробнее здесь: [url]https://stackoverflow.com/questions/36455162/getting-empty-collection-from-a-query[/url]
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»