Support the ongoing development of Laravel.io →
Requests Database Eloquent

Developers, I'm doing a search function and I can not bring the variable into sql? can anyone help, my code:

public function search(Request $request){
    {
        $search = $request->input('q');
        
        $grupo = Grupo::where('nome', 'like','%'.$request->input('q').'%')
                        ->orWhere('sku','like','%'.$request->get('q').'%')->toSql();

    //    dd($request);
        

        echo "My search string: ".$request->input('q');
        echo "<br>";
        echo "Query: ".$grupo;
        //return view('anuncios')->with('grupos', $search);
    }

the return in html: My search string: oto Query: select * from grupos where nome like ? or sku like ?

any idea?

Last updated 3 years ago.
0

please refer to this link. [https://stackoverflow.com/questions/32372437/does-laravels-tosql-method-mask-ids-column-value-being-replaced-by-question]

Last updated 6 years ago.
0

Thanks for the help, I solved my problem

0

I would suggest you to check out Laravel 5.8 tutorials or docs to check the issue.

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Osvaldo offsys Joined 23 May 2019

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.