Skip to content

Instantly share code, notes, and snippets.

@AleeRojas
Last active April 19, 2016 19:39
Show Gist options
  • Save AleeRojas/56e48f92efaf9ef51ae96f59e187dd55 to your computer and use it in GitHub Desktop.
Save AleeRojas/56e48f92efaf9ef51ae96f59e187dd55 to your computer and use it in GitHub Desktop.
Left Join Laravel
<?php
$model = $model->leftJoin('history', function ($join) {
$join->on('history.record_id', '=', 'work_order.work_order_id');
$join->where('history.tablename', '=', 'test');
$join->where('history.columnname', '=', 'column');
$join->where(DB::raw('(`history`.`value_from` = 0 or `history`.`value_from` = "")'), '', '');
$join->where('history.value_to', '>', '0');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment