annotate src/Database/Builder.php @ 2:b44434aaa767

Moving around the components. Made a big step in the right direction with the Builder and named joins being accessible.
author luka
date Wed, 18 Jun 2025 22:28:47 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
1 <?php
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
2
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
3 namespace Wizard\Framework\Database;
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
4
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
5 use Illuminate\Database\Eloquent\Builder as BaseBuilder;
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
6
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
7 class Builder extends BaseBuilder {
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
8
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
9 public $named_joins = [];
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
10
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
11 /*
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
12 * Add's a named join to the query, this will only add the joins
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
13 * a single time, and keep track of joins that are already in the query.
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
14 *
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
15 */
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
16 public function addNamedJoin($join = '') {
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
17 $available_joins = $this->model?->named_joins() ?? [];
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
18 if(isset($available_joins[$join]) && ($named_joins[$join] ?? false) == false) {
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
19 $this->named_joins[$join] = true;
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
20 $available_joins[$join]($this);
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
21 }
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
22 }
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
23 }