Debug School

rakesh kumar
rakesh kumar

Posted on

How to get array of value from database records in laravel

Step 1:get the collection of records

$pay_users = addcart::where('admin_id', $param3)->get();
Enter fullscreen mode Exit fullscreen mode

step2: store the array of 'influencer_admin_id' values from the records in the $pay_users collection.

$influencer_adminids = $pay_users->pluck('influencer_admin_id')->toArray();
Enter fullscreen mode Exit fullscreen mode

output

$influencer_adminids = ['123', '456', '789'];
Enter fullscreen mode Exit fullscreen mode

or

[2023-10-31 05:24:30] local.INFO: array (
  0 => 123,
  1 => 456,
)  
Enter fullscreen mode Exit fullscreen mode

Top comments (0)