Engineering note · Laravel

Sanitize Input to Prevent SQL Injection

By Published Updated

Laravel

Always use Eloquent ORM or Laravel's query builder to interact with the database, which automatically prevents SQL injection by binding parameters.

CODE SAMPLE Code snippet
// Using Eloquent ORM
$user = User::where('email', $request->input('email'))->first();

// Using Query Builder
$users = DB::table('users')->where('email', $request->input('email'))->get();

More engineering notes

Custom Blade Directives in Laravel

Laravel allows you to create custom Blade directives, making it easier to reuse and organize common...

Optimize Database Query Usage with Eager Loading

Use eager loading (with() method) in your controller to load related models with fewer database quer...