Using Array In '->where()' For Laravel Query Building
I am trying to get all values of a column, and then use it in another query. I used
lists and got the values as an array but, I couldn't find the way to check that variable (array containing each id) in other query
$subscribes = Subscribe::where('from_id', $currentUser)->lists('id') // dd($subscribes), logs values as array. $videos = Photo::where('id', $subscribes)->get();
This doesn't work because $subscribes is an array.
Should I use a for loop and send another query for each id? Or is there a practical way that I am missing out? What is the proper way of using it?
$videos = Photo::whereIn('id', $subscribes)->get();
http://laravel.com/docs/5.1/queries (scroll down / search 'whereIn')
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?