I am new to Laravel and I am trying to search for product using nearby shops Here is my code
Shop::selectRaw(" id ,
( 6371 * acos( cos( radians(?) ) *
cos( radians( lat ) )
* cos( radians( lng ) - radians(?)
) + sin( radians(?) ) *
sin( radians( lat ) ) )
) AS distance", [$latitude, $longitude, $latitude])
->having("distance", "<", $radius)
->orderBy("distance",'asc')->products()->where('name', 'LIKE', '%' . $keyword . '%')->get();
But I am getting this error message:
"message": "Call to undefined method Illuminate\Database\Eloquent\Builder::products()"
Note: The Relationship between shop and product is working in my other functions