I have a table with 5 millions records and it has duplicated rows
I want to remove the duplication.
This is my code
$userRoles = Model::groupBy('phone','user_id','name')->get(); $userRolesId = array_column($userRoles ->toArray(), 'id'); Model::whereNotIn('id', $userRolesId )->delete();
URL exists but it returns an error after five minutes of loading. And when I tried it for a small table it works perfectly.
Advertisement
Answer
404 that mean you call route not exist in your application ,
If the incoming request does not match the route pattern constraints, a 404 HTTP response will be returned. no problem in your code :-
$userRoles = Model::groupBy('phone','user_id','name')->get(); $userRolesId = array_column($userRoles ->toArray(), 'id'); Model::whereNotIn('id', $userRolesId )->delete();