1
I’m working with Laravel and was looking at a bootstrap template to customize the application and came across this format to display the followers:
My question is how could treat the array that brings my users only with the photo and if the array is larger than 3 as in the example bring the count of other users.
Edit:
$network_users = User::select('photo')->where('parent', Auth::user()->id)->get()->toArray();
$network_images = array();
foreach ($network_users as $user) {
if (count($network_users) >= 4) {
$count = count($network_users) - 4;
array_push($network_images, $user);
} else {
$count = count($network_users);
array_push($network_images, $user);
}
}
$data = array(
'count' => $count,
'network_images' => $network_images
);
dd($data);
I set up in this format followed by the idea of using the Count, this would be the most correct way to bring the data or would have some better way?
Use the Count method
– Eduardo Gonçalves