0
votes

I have a mysql query

SELECT * FROM Appraisal_skills WHERE INSTR(`assigned_to`, 6);

Which working well.I want to change this to laravel

I tried

$getskillset=Db::table('Appraisal_skills')->where(`assigned_to`, 6)->instr()->get();

But got an error like BadMethodCallException in Builder.php line 2508: Call to undefined method Illuminate\Database\Query\Builder::instr()

Please correct me.Any help would be appreciated.

1

1 Answers

2
votes

Laravels database query builder doesn't have instr method. But you can use whereRaw method.

So your code will be like this

$getskillset=Db::table('Appraisal_skills')->whereRaw('INSTR(`assigned_to`, ?)', [6])->get();

You can read more about raw expressions in Laravel docs

and here is api documentation