Skip to content
Advertisement

Tag: laravel

How can I secure this sql query from SQL Injection in Laravel?

I am trying to create restAPI in Laravel. How can I secure an SQL query like this from sql injection? Answer Laravel’s database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application and works on all supported database systems. The Laravel query builder uses

Laravel Eloquent: select records where one field equals another

I apologize if this is duplicated. Is it possible in Eloquent ORM to select records where one field equals another? In MySQL this means: Is it possible to do so in Eloquent or I’m bound to using raw queries? Answer On field equalling another in the query builder (and eloquent) is whereColumn(‘Url’, ‘LIKE’, ‘ModelId’) but since you have additional things

Convert Query to Eloquent

How to make that query with eloquent My relationships I fetching the name with a given ID, but how can I find it for all. Or maybe I am thinking wrong Answer I assumed your employees Model name as Employee and companies Model name as Company If you want to search per id then you may do as below.

Advertisement