3
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
* Time: 14:56
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Traits;
|
||||
|
||||
|
||||
@@ -224,9 +225,12 @@ trait QueryTrait
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function leftJoin($tableName, $alias, $onCondition, $param = NULL)
|
||||
public function leftJoin(string $tableName, string $alias, $onCondition, $param = NULL)
|
||||
{
|
||||
if ($tableName instanceof ActiveRecord) {
|
||||
if (class_exists($tableName)) {
|
||||
if (!in_array(ActiveRecord::class, class_implements($tableName))) {
|
||||
throw new Exception('Model must implement ' . $tableName);
|
||||
}
|
||||
$tableName = $tableName::getTable();
|
||||
}
|
||||
return $this->join(...["LEFT JOIN " . $tableName, $alias, $onCondition, $param]);
|
||||
@@ -242,7 +246,10 @@ trait QueryTrait
|
||||
*/
|
||||
public function rightJoin($tableName, $alias, $onCondition, $param = NULL)
|
||||
{
|
||||
if ($tableName instanceof ActiveRecord) {
|
||||
if (class_exists($tableName)) {
|
||||
if (!in_array(ActiveRecord::class, class_implements($tableName))) {
|
||||
throw new Exception('Model must implement ' . $tableName);
|
||||
}
|
||||
$tableName = $tableName::getTable();
|
||||
}
|
||||
return $this->join(...["RIGHT JOIN " . $tableName, $alias, $onCondition, $param]);
|
||||
@@ -258,7 +265,10 @@ trait QueryTrait
|
||||
*/
|
||||
public function innerJoin($tableName, $alias, $onCondition, $param = NULL)
|
||||
{
|
||||
if ($tableName instanceof ActiveRecord) {
|
||||
if (class_exists($tableName)) {
|
||||
if (!in_array(ActiveRecord::class, class_implements($tableName))) {
|
||||
throw new Exception('Model must implement ' . $tableName);
|
||||
}
|
||||
$tableName = $tableName::getTable();
|
||||
}
|
||||
return $this->join(...["INNER JOIN " . $tableName, $alias, $onCondition, $param]);
|
||||
|
||||
Reference in New Issue
Block a user