I
I
isMobile2019-01-31 12:59:55
Laravel
isMobile, 2019-01-31 12:59:55

Laravel 5.7 DB::Select array argument?

Good afternoon everyone.
Whether prompt it is possible to make selection somehow if as argument an array.
$category = DB::table('sd_category')->where('user', Auth::user()->id)->get();
Then I tried to run through
foreach ($categorys as $category) {
$task = DB::table('tasks')->where('category', $category->name)->orderBy('id', 'desc' )->paginate(15);
}
But in $task I get only the result of the last passage of foreach.
How can this be bypassed? Please let me know if anyone has experienced something similar.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rikcon, 2019-01-31
@isMobile

It's NOT IN FOREACH
PS if it's correct categories and not
categories

F
FernandoErrNando, 2019-01-31
@FernandoErrNando

the loop writes to a variable and not to an array, why should it show not the last element?
Write it to an array, and then substitute it in whereIn.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question