dimanche 28 février 2016

Laravel 5.1 Eloquent collection not returning correct results

I have an eloquent collection {{ $questions }}, when i output it inside a blade template i get the following results:

[{"question_num":0,"survey_id":2,"question_text":"test","expected_answer":1},
  {"question_num":1,"survey_id":2,"question_text":"test","expected_answer":1}] 

As you can see there are exactly two objects. Now when I apply this filter {{ $questions->where('question_num','=', 0) }}, I get the following results which is correct:

[{"question_num":0,"survey_id":2,"question_text":"test","expected_answer":1}] 

But when I apply the following filter {{ $questions->where('question_num','=', 1) }}, I get an empty result, why is that, when clearly the collection has a question_num with value of 1?

[]

I've been scratching my head all day with this!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire