Toninho Posted February 10, 2023 at 12:56 AM Report Share #630128 Posted February 10, 2023 at 12:56 AM Salve, essa query não esta funcionando, quero pesquisar em 3 tabela $keyword=ucwords(strtolower(str_replace('-'," ", $urcityy[2]))); $data = Empresa::where('city',$urcityyyy)->where('title','like','%'.$keyword.'%') ->orWhereHas('empregos', function($q) use ($keyword){ return $q->where('title','like','%'. $keyword . '%')->where('city',$urcityyyy); }) ->orWhereHas('eventos', function($q) use ($keyword){ return $q->where('title','like','%'. $keyword . '%')->where('city',$urcityyyy); })->get(); Grato Link to comment Share on other sites More sharing options...
messhias Posted March 27, 2023 at 07:04 PM Report Share #630537 Posted March 27, 2023 at 07:04 PM (edited) On 2/10/2023 at 12:56 AM, Toninho said: Salve, essa query não esta funcionando, quero pesquisar em 3 tabela $keyword=ucwords(strtolower(str_replace('-'," ", $urcityy[2]))); $data = Empresa::where('city',$urcityyyy)->where('title','like','%'.$keyword.'%') ->orWhereHas('empregos', function($q) use ($keyword){ return $q->where('title','like','%'. $keyword . '%')->where('city',$urcityyyy); }) ->orWhereHas('eventos', function($q) use ($keyword){ return $q->where('title','like','%'. $keyword . '%')->where('city',$urcityyyy); })->get(); Grato Aparentemente você está a utilizar Laravel correcto (ou algum framework muito parecido com que usa o Builder do Eloquent)? Sua query é muito complexa e eu oriento neste caso a utilizar uma raw query por exemplo: SELECT <campos> from <tabela principal> left join <tabela 1> on <tabela principal>.<campo> = <tabela 2>.<campo co-relato> left join <tabela 2> on <tabela principal>.<campo> = <tabela 3>.<campo co-relato> left join <tabela 3> on <tabela principal>.<campo> = <tabela 3>.<campo co-relato> where <campos que você citou acima> Edited March 27, 2023 at 07:04 PM by messhias Editar campos para melhor visualização Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now