vendredi 17 juillet 2020

How to use alias column in whereIn with Laravel?

here is my code. I am trying to get new list of A items in order to loop on.

 $allowed_a = \App\NewA::select('name')->get()->pluck('name');        
 $a = App\A::selectRaw("replace(unaccent(trim(name)), ' ', '') AS newname, name")
             ->whereIn('newname', $allowed_a)->get();

But I am getting Undefined column 'newname'. How can I fix it please? thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire