Skip to content

Instantly share code, notes, and snippets.

@rickslayer
Last active December 19, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickslayer/502731d714cd547059252dea3acf865e to your computer and use it in GitHub Desktop.
Save rickslayer/502731d714cd547059252dea3acf865e to your computer and use it in GitHub Desktop.
--Simple Where
Model::where('field', '*operator', 'value').
//*operator = "< , >, =, =>, =< etc"
-- Between where
Model::whereBetween('field',['value1', 'value2']);
-- Raw Where for exclusive treatments
Model::whereRaw('LEFT(field, 4) = tesssttteeee')
//Left JOin
Model:leftJoin('table', 'table.id', '=', 'Model id')
//If in where
->when($filter, function($q) {
return $q->where("field", '=', 0);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment