mercredi 2 mai 2018

Laravel 5 query builder, complicated join (condition AND (condition OR condition))

I need to reproduce the following query in Laravel's query builder:

select * from table LEFT JOIN table_b ON `condition` AND (`condition` OR `condition`)

I know you can do complicated where statements like this:

Model::where(function ($query) {
  return $query->where("field","value")->orWhere("field","value");
})->where("field","value")->get();

And I know you can do semi-complicated on statements like this:

->leftJoin('table', function ($join) {
  $join->on("field","=","field_b")
    ->on("field_a","=","field_c");
})

But I need to have condition AND (condition OR condition) INSIDE an on statement. Is this possible without doing DB::raw() or equivalent?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2JObr9n
via IFTTT

Aucun commentaire:

Enregistrer un commentaire