diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Database/Builder.php	Wed Jun 18 22:28:47 2025 -0400
@@ -0,0 +1,23 @@
+<?php
+
+namespace Wizard\Framework\Database;
+
+use Illuminate\Database\Eloquent\Builder as BaseBuilder;
+
+class Builder extends BaseBuilder {
+	
+	public $named_joins = [];
+
+	/*
+	 * Add's a named join to the query, this will only add the joins
+	 * a single time, and keep track of joins that are already in the query.
+	 *
+	 */
+	public function addNamedJoin($join = '') {
+		$available_joins = $this->model?->named_joins() ?? [];
+		if(isset($available_joins[$join]) && ($named_joins[$join] ?? false) == false) {
+			$this->named_joins[$join] = true;
+			$available_joins[$join]($this);
+		}
+	}
+}