Created
November 6, 2017 20:37
-
-
Save brunokunace/240b61b30416cce101b6aed5b0ca6e9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function test() | |
{ | |
$cityName = "Viamão"; | |
$stateInitials = "RS"; | |
$states = DB::table('estado') | |
->join('cidade', function ($join) use ($cityName, $stateInitials) { | |
$join->on('cidade.Estado_ID', '=', 'estado.ID') | |
->where('cidade.NomeCidade', '=', $cityName); | |
}) | |
->where('estado.Sigla', '=', $stateInitials) | |
->toSQL(); | |
return response()->json($states, 200); | |
} | |
//Select cidade.ID | |
//from estado | |
//Inner Join cidade on cidade.Estado_ID = estado.ID and cidade.NomeCidade = "Viamão" | |
//Where estado.Sigla = "RS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment