Level 88
It is right now! You need to do it like so
$search = 'something';
$raw = DB::raw('(SELECT * FROM cars WHERE cars.title like :search) cars', ['search' => '%' . $search . '%');
Form::crossJoin($raw)->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
up vote 0 down vote favorite In laravel if i have a model FORM and table cars, is it safe to use raw query like this: Form::crossJoin(DB::raw('(SELECT * FROM cars WHERE cars.title like "%somewords%")cars'))->get(); In this case i used like operator for search. Is it vulnerable for sql injection? If yes, how make it safe?
Please or to participate in this conversation.