-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability for different where clauses
- Loading branch information
Showing
4 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Fico7489\Laravel\EloquentJoin\Services; | ||
|
||
class QueryNormalizer | ||
{ | ||
public static function normalize($parameters) | ||
{ | ||
$firstParam = array_values($parameters)[0]; | ||
|
||
if (is_array($firstParam)) { | ||
$parametersNew = []; | ||
foreach ($firstParam as $k => $v) { | ||
$parametersNew = [$k, '=', $v]; | ||
} | ||
} elseif (count($parameters) == 2) { | ||
$secondParam = array_values($parameters)[1]; | ||
$parametersNew = [$firstParam, '=', $secondParam]; | ||
} else { | ||
$parametersNew = $parameters; | ||
} | ||
|
||
return $parametersNew; | ||
} | ||
|
||
public static function normalizeScope($parameters) | ||
{ | ||
unset($parameters[0]); | ||
$parameters = array_values($parameters); | ||
|
||
return self::normalize($parameters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters