|
2
|
1 <?php
|
|
|
2
|
|
|
3 namespace Wizard\Framework\Database;
|
|
|
4
|
|
|
5 use Illuminate\Database\Eloquent\Builder as BaseBuilder;
|
|
|
6
|
|
|
7 class Builder extends BaseBuilder {
|
|
|
8
|
|
|
9 public $named_joins = [];
|
|
|
10
|
|
|
11 /*
|
|
|
12 * Add's a named join to the query, this will only add the joins
|
|
|
13 * a single time, and keep track of joins that are already in the query.
|
|
|
14 *
|
|
|
15 */
|
|
|
16 public function addNamedJoin($join = '') {
|
|
|
17 $available_joins = $this->model?->named_joins() ?? [];
|
|
|
18 if(isset($available_joins[$join]) && ($named_joins[$join] ?? false) == false) {
|
|
|
19 $this->named_joins[$join] = true;
|
|
|
20 $available_joins[$join]($this);
|
|
|
21 }
|
|
|
22 }
|
|
|
23 }
|