Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save armyofda12mnkeys/74743d264ace8e74779bd1ab8be7957c to your computer and use it in GitHub Desktop.
Save armyofda12mnkeys/74743d264ace8e74779bd1ab8be7957c to your computer and use it in GitHub Desktop.
$data = SomeModel:join('table2', 'column1', 'column2')
->join('table3', 'column1', 'column2')
->where table1.some_column = 'x'
->where table2.some_column = 'y'
->where table3.some_column = 'z'
->orderBy('table2.score')
->select('column1,column2,column3')
->distinct();
When i do a ->toSql() and review the query i see it includes deleted rows of table 2 or table 3 so i have to explicitly remove with something like this:
->whereNull('table2.deleted_at')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment