Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions src/Builder/Concerns/CoreMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,12 +742,9 @@ public function havingInSub(string $column, Closure $callback, string $boolean =

/**
* Ajoute une clause HAVING BETWEEN
*
* @param mixed $value1
* @param mixed $value2
*/
public function havingBetween(string $column, $value1, $value2, string $boolean = 'and', bool $not = false): static
{
public function havingBetween(string $column, mixed $value1, mixed $value2, string $boolean = 'and', bool $not = false): static
{
return $this->addCondition('havings', 'between', [
'column' => $column,
'values' => [$value1, $value2],
Expand All @@ -758,33 +755,24 @@ public function havingBetween(string $column, $value1, $value2, string $boolean

/**
* Ajoute une clause HAVING NOT BETWEEN
*
* @param mixed $value1
* @param mixed $value2
*/
public function havingNotBetween(string $column, $value1, $value2, string $boolean = 'and'): static
public function havingNotBetween(string $column, mixed $value1, mixed $value2, string $boolean = 'and'): static
{
return $this->havingBetween($column, $value1, $value2, $boolean, true);
}

/**
* Ajoute une clause HAVING BETWEEN avec OR
*
* @param mixed $value1
* @param mixed $value2
*/
public function orHavingBetween(string $column, $value1, $value2): static
public function orHavingBetween(string $column, mixed $value1, mixed $value2): static
{
return $this->havingBetween($column, $value1, $value2, 'or');
}

/**
* Ajoute une clause HAVING NOT BETWEEN avec OR
*
* @param mixed $value1
* @param mixed $value2
*/
public function orHavingNotBetween(string $column, $value1, $value2): static
public function orHavingNotBetween(string $column, mixed $value1, mixed $value2): static
{
return $this->havingNotBetween($column, $value1, $value2, 'or');
}
Expand Down
36 changes: 0 additions & 36 deletions src/Builder/Concerns/ProxyMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,6 @@
* @method static notWhereColumn(array|string $first, string $operator = null, string $second = null, string $boolean = 'and') Alias de whereNotColumn() - Ajoute une clause WHERE avec comparaison de colonnes inversée
* @method static orNotWhereColumn(array|string $first, string $operator = null, string $second = null) Alias de orWhereNotColumn() - Ajoute une clause WHERE avec comparaison de colonnes inversée avec OR
*
* // Conditions HAVING
* @method static havingIn(string $column, array|\Closure $values, string $boolean = 'and', bool $not = false) Alias de havingIn() - Ajoute une clause HAVING IN
* @method static havingNotIn(string $column, array|\Closure $values, string $boolean = 'and') Alias de havingNotIn() - Ajoute une clause HAVING NOT IN
* @method static orHavingIn(string $column, array|\Closure $values) Alias de orHavingIn() - Ajoute une clause HAVING IN avec OR
* @method static orHavingNotIn(string $column, array|\Closure $values) Alias de orHavingNotIn() - Ajoute une clause HAVING NOT IN avec OR
* @method static havingLike(string $column, string $value, string $side = 'both', string $boolean = 'and', bool $not = false, bool $caseSensitive = false) Alias de havingLike() - Ajoute une clause HAVING LIKE
* @method static notHavingLike(string $column, string $value, string $side = 'both', string $boolean = 'and', bool $caseSensitive = false) Alias de havingNotLike() - Ajoute une clause HAVING NOT LIKE
* @method static orHavingLike(string $column, string $value, string $side = 'both', bool $caseSensitive = false) Alias de orHavingLike() - Ajoute une clause HAVING LIKE avec OR
* @method static orHavingNotLike(string $column, string $value, string $side = 'both', bool $caseSensitive = false) Alias de orHavingNotLike() - Ajoute une clause HAVING NOT LIKE avec OR
* @method static havingBetween(string $column, mixed $value1, mixed $value2, string $boolean = 'and', bool $not = false) Alias de havingBetween() - Ajoute une clause HAVING BETWEEN
* @method static havingNotBetween(string $column, mixed $value1, mixed $value2, string $boolean = 'and') Alias de havingNotBetween() - Ajoute une clause HAVING NOT BETWEEN
* @method static orHavingBetween(string $column, mixed $value1, mixed $value2) Alias de orHavingBetween() - Ajoute une clause HAVING BETWEEN avec OR
* @method static orHavingNotBetween(string $column, mixed $value1, mixed $value2) Alias de orHavingNotBetween() - Ajoute une clause HAVING NOT BETWEEN avec OR
* @method static havingNull(string $column, string $boolean = 'and', bool $not = false) Alias de havingNull() - Ajoute une clause HAVING NULL
* @method static havingNotNull(string $column, string $boolean = 'and') Alias de havingNotNull() - Ajoute une clause HAVING NOT NULL
* @method static orHavingNull(string $column) Alias de orHavingNull() - Ajoute une clause HAVING NULL avec OR
* @method static orHavingNotNull(string $column) Alias de orHavingNotNull() - Ajoute une clause HAVING NOT NULL avec OR
*
* // Tri
* @method static sortAsc(string|array $column) Alias de orderBy() avec direction ASC - Ajoute un tri croissant
* @method static sortDesc(string|array $column) Alias de orderBy() avec direction DESC - Ajoute un tri décroissant
Expand Down Expand Up @@ -135,24 +117,6 @@ trait ProxyMethods
'notWhereColumn' => 'whereNotColumn',
'orNotWhereColumn' => 'orWhereNotColumn',

// Conditions HAVING
'havingIn' => 'havingIn',
'havingNotIn' => 'havingNotIn',
'orHavingIn' => 'orHavingIn',
'orHavingNotIn' => 'orHavingNotIn',
'havingLike' => 'havingLike',
'notHavingLike' => 'havingNotLike',
'orHavingLike' => 'orHavingLike',
'orHavingNotLike' => 'orHavingNotLike',
'havingBetween' => 'havingBetween',
'havingNotBetween' => 'havingNotBetween',
'orHavingBetween' => 'orHavingBetween',
'orHavingNotBetween'=> 'orHavingNotBetween',
'havingNull' => 'havingNull',
'havingNotNull' => 'havingNotNull',
'orHavingNull' => 'orHavingNull',
'orHavingNotNull' => 'orHavingNotNull',

// Tri
'sortAsc' => 'orderBy',
'sortDesc' => 'orderBy',
Expand Down
22 changes: 11 additions & 11 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -961,23 +961,23 @@ public function __isset(string $name): bool
*/
public function __call(string $name, array $arguments)
{
// Méthodes du Query Builder
if (method_exists($this->builder(), $name)) {
$result = $this->builder()->{$name}(...$arguments);
// Méthodes du Query Builder
try {
$result = $this->builder()->{$name}(...$arguments);

// Si le résultat est une instance du builder, retourner $this pour la fluidité
if ($result instanceof BaseBuilder) {
return $this;
}

return $result;
}

// Méthodes de la connexion
if (method_exists($this->db, $name)) {
return $this->db->{$name}(...$arguments);
}

throw new BadMethodCallException("Method {$name} not found in " . static::class);
} catch (BadMethodCallException) {
// Méthodes de la connexion
try {
return $this->db->{$name}(...$arguments);
} catch (BadMethodCallException) {
throw new BadMethodCallException("Method {$name} not found in " . static::class);
}
}
}
}