Get all routes that start with rt_
One way to simplify this would be to create a collection with collect() and then call getName() on each route using Collection::map(). Then use collection::filter() to filter out the routes that don't start with rt_ using the string helper method Str::startsWith()
class RouteController extends Controller {
    public function getRoutes()
    { 
        // call getName on each route and then get unique values
        $uniqueRoutes = collect(Route::getRoutes())
            -&gt;map(fn($route) =&gt; $route-&gt;getName())
            -&gt;unique(); 
        //filter out any routes not starting with rt_
        $filteredRoutes = $uniqueRoutes-&gt;filter(function($name) {
             return Str::startsWith($name, 'rt_');
        });
        return response()-&gt;json($filteredRoutes, 200); 
    }
}

Note - the uses the PHP 7.4 arrow function syntax could be used to simplify the callback to the filter() method
One could also use collection::reduce() to only add routes to the list that contain the desired prefix.

The existing code contains this block:

          //Filering duplicates
           foreach ($array as $item) {
               if ($item == $route-&gt;getName()) {
                   $found = TRUE;
               }
           }


That could be simplified using the PHP function in_array().

Another suggestion is to always use strict equality comparisons (i.e. === and !==) when possible - e.g. when $found should either be true or false then compare without the possibility of type conversion (i.e. with ==).