Morphable field not working for Laravel DB::Select() statement

  laravel, mysql

I need to use DB::select() statement for a complex query I´m working on that is not returning any results. After some diggin I found out the reason was that the model_type field comparison was not working regardless wheather I use this sintaxis:

select *
from questions
where model_type = "AppModelsProduct"

Or this sintaxis:

select * 
from questions
where model_type = "AppModelsProduct"

Even though the second sentence works perfectly on MySQL Workbench, it returns no results in Laravel.
The MySQL table field name is of course model_type and the values are hold as: AppModelsProduct and all relationships work perfectly. It seems that there should be a way to specify to Laravel how to compare the values, but I haven´t found it.
Please note that I have to use DB::select() as oposed to Eloquent, since my actual query deals with MySQL MATCH() AGAINST() and some other complexities.

Any help would be welcome. Txs!

Source: Laravel

Leave a Reply