0

hello i am facing problem in where condition laravel. i have two array

$a = [▼
  0 => 2
  1 => 9
  2 => 39
  3 => 174
  4 => 190
];

$b = [▼
  0 => 2
  1 => 9
  2 => 39
  3 => 174
  4 => 190
  5 => 0
];

**array values is ids.  i tried array_values($a) && array_values($b) 
i want ids like this  but not get same response.**

[ 2 ,9 ,39 ,174 ,190] && [ 2 ,9 ,39 ,174 ,190 , 0 ]

trying to get data from query like

$classrooms = Classroom::where('teacher_id', $teacherId)
                ->where('school_curriculum_id', [$b])
                ->where('hybrid_curriculum', [$b])->get();

but got null . something wrong in where condition. please help me to solve this.

protected $fillable = [
        'id', 'school_id', 'grade_id', 'teacher_id', 'school_curriculum_id', 'name', 'deleted', 'deleted_date', 'archived', 'is_hybrid', 'hybrid_curriculum', 'hybrid_grade', 'enable_auto_submit_assessment', 'timeline_type', 'timeline_modified', 'group_test_by', 'created', 'modified', 'enable_auto_lockout_unit',
    ];
2
  • What is your table structure? Commented Apr 15, 2021 at 6:47
  • have you tried whereIn instead of where? Commented Apr 15, 2021 at 6:49

1 Answer 1

1

Can you try this:


$classrooms = Classroom::where('teacher_id', $teacherId)
                ->whereIn('school_curriculum_id', $b)
                ->whereIn('hybrid_curriculum', $b)->get();

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.