Unable to search data in a mongodb database using laravel

I am trying to write a query to search the mongodb database for a specific query and return the associated information here is what I have done so far:
In Post:

<?php 
namespace AppModels;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use JenssegersMongodbEloquentModel;
class Post extends Model
{

use HasFactory;
protected $connection = 'mongodb';
protected $collection = 'post';
protected $fillable = [
'STATUS',
'DDC_CODE',

'TRADE_NAME',

'SCIENTIFIC_CODE',

'SCIENTIFIC_NAME',

'INGREDIENT_STRENGTH',

'DOSAGE_FORM_PACKAGE',

'ROUTE_OF_ADMIN',
'PACKAGE_PRICE',

'GRANULAR_UNIT',

'MANUFACTURER',

'REGISTERED_OWNER',

'UPDATED_DATE',

'SOURCE'
];}

In PostController:

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsPost;

class PostController extends Controller
{

public function home() {
    $posts = Post::paginate(4);

    return view('home', compact('posts'));
}
public function search(Request $request){
    
    if(isset($_GET['query'])){
        $search_text=$_GET['query'];
        $searchs=Post::whereRaw(array('$text'=>array('$search'=> $search_text)))->get();;
        return view('search',['searchs'=>$searchs]);
    }
    else{
        return view('search');
    }
 }
}

And the search.blade.php:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laravel search</title>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-6" style="margin-top:40px">
            <h4>Search Everything</h4><hr>
            <form action="{{ route('web.search')}}" method="GET">
                <div class="form-group">
                    <label for="">Enter keyword</label>
                    <input type="text" class="form-control" name="query" placeholder="Search here...">
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary">Search</button>
                </div>
            </form>
            <br>
            <br>
            <hr>
            <br>
            <table border = "1">
            <tr>
            <td>STATUS</td>
            <td>DDC_CODE</td>
            <td>TRADE_NAME</td>
            <td>SCIENTIFIC_CODE</td>
            <td>SCIENTIFIC_NAME</td>
            <td>SCIENTIFIC_CODE</td>
            <td>INGREDIENT_STRENGTH</td>
            <td>DOSAGE_FORM_PACKAGE</td>
            <td>ROUTE_OF_ADMIN</td>
            <td>PACKAGE_PRICE</td>
            <td>GRANULAR_UNIT</td>
            <td>MANUFACTURER</td>
            <td>UPDATED_DATE</td>
            <td>SOURCE</td>
            </tr>
            @foreach ($searchs as $search)
            <tr>

            <td>{{ $search['STATUS'] }}</td>
            <td>{{ $search['DDC_CODE'] }}</td>
            <td>{{ $search['TRADE_NAME'] }}</td>
            <td>{{ $search['SCIENTIFIC_CODE'] }}</td>
            <td>{{ $search['SCIENTIFIC_NAME'] }}</td>
            <td>{{ $search['INGREDIENT_STRENGTH'] }}</td>
            <td>{{ $search['DOSAGE_FORM_PACKAGE'] }}</td>
            <td>{{ $search['ROUTE_OF_ADMIN'] }}</td>
            <td>{{ $search['PACKAGE_PRICE'] }}</td>
            <td>{{ $search['GRANULAR_UNIT'] }}</td>
            <td>{{ $search['MANUFACTURER'] }}</td>
            <td>{{ $search['REGISTERED_OWNER'] }}</td>
            <td>{{ $search['UPDATED_DATE'] }}</td>
            <td>{{ $search['SOURCE'] }}</td>
            </tr>
            @endforeach
            </table>
</body>
</html>

Also the route handler web.php:

<?php

use IlluminateSupportFacadesRoute;
use AppHttpControllersPostController;

Route::get('/', function () {
     return view('welcome');
});
Route::get('view','AppHttpControllersPostController@home');
Route::get('/search',[PostController::class,'search'])- 
>name('web.search');

When I run the code for some reason it gives me a ErrorException Undefined variable: searchs in the search.blade.php and marks the first line of the loop. Also there is no problems with the connection itself as the home method in the postController runs flawlessly. I believe there is one of two possibilities the query in my post controller is wrong and is therefore causing the error or something is wrong in the blade file not sure which. Any and all help is appreciated.