Incorporating a Eloquent Raw Query into a chained query

Posted 3 years ago by domioanna

I have a raw query, as follows:-

$results = DB::select(
            DB::raw(
                'SELECT *, ( 3959 * acos( 
                    cos( 
                        radians(' . $lat . ') 
                    ) * cos( 
                        radians( latitude )
                    ) * cos( 
                        radians( longitude ) - radians(
                            ' . $lng . '
                        )
                    ) + sin( 
                        radians(
                            ' . $lat .'
                        )
                    ) * sin( 
                        radians(
                            latitude
                        )
                    )
                ) 
            )
            AS distance FROM properties HAVING distance < ' . $distance . ' ORDER BY distance') );

        return $results;

...which works find for getting ALL properties, but I need to get all of the logged in users properties AND apply a where clause onto a joined table 'strategies'.

Any ideas?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.