'Get Data from Database using array value as search key -

Good Morning.. I stuck at one point where i need to search and get the data from database from array value as key. Let me Explain - Ref image for table - Under buffaloID - i have 1 record on each day for each buffaloID. so next day buffaloID repeat with new data. I need to get data of 7 days for totalmilk for each buffaloID. Now i stuck as buffaloID are changing when new member added or deleted. So i make array of buffaloid so from array i can search each buffaloID and get required data. Code to get array -

               $getbuffaloID = DB::table('Buffalomilkrecord')
                               ->select('buffaloID')
                               ->groupBy('buffaloID')
                               ->pluck('buffaloID')->toArray();;
Ourput is 
array:3 [▼
       0 => "Buffalo-01"
       1 => "Buffalo-02"
       2 => "Buffalo-03"
      ]

So let me help to complete the code....

I hope i explain my required clearly. and thanks in advance ...

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source