I am using a query that returns value perfectly but it adds key number to the collection. How can I remove the index number?
Here is the retrieved data
You have to do it manually
$users=\App\User::get()->toArray(); // your query here
$data['data']=[];
foreach($users as $user ){
$data['data'][]=$user;
}
$k=json_encode($data); dd($k);
In order to get a collection without a index you have to add the "values" method
$collection->unique('id')->values();