-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from nguyenanhung/v4.x
Release version 4.0.6
- Loading branch information
Showing
2 changed files
with
52 additions
and
13 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 |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
interface Environment | ||
{ | ||
public const PROJECT_NAME = 'My Database Packages by HungNG'; | ||
public const VERSION = '4.0.5'; | ||
public const LAST_MODIFIED = '2024-09-11'; | ||
public const VERSION = '4.0.6'; | ||
public const LAST_MODIFIED = '2024-09-12'; | ||
public const AUTHOR_NAME = 'Hung Nguyen'; | ||
public const AUTHOR_EMAIL = '[email protected]'; | ||
public const AUTHOR_URL = 'https://nguyenanhung.com'; | ||
|
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 |
---|---|---|
|
@@ -777,27 +777,51 @@ public function buildOperatorSpaceShipTo(Builder $db, $id, string $field = 'id', | |
* | ||
* @param \Illuminate\Database\Query\Builder $db | ||
* @param $orderByField | ||
* @param string $defaultField | ||
* @param mixed $table | ||
* @param $defaultField | ||
* @param $table | ||
* @param $tmpTable | ||
* @param $tmpField | ||
* | ||
* @return \Illuminate\Database\Query\Builder | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 07/02/2023 28:46 | ||
*/ | ||
public function bindOrderBy(Builder $db, $orderByField, string $defaultField = 'updated_at', $table = null): Builder | ||
{ | ||
public function bindOrderBy( | ||
Builder $db, | ||
$orderByField, | ||
$defaultField = 'updated_at', | ||
$table = null, | ||
$tmpTable = null, | ||
$tmpField = null | ||
) { | ||
if (empty($table)) { | ||
$table = $this->table; | ||
} | ||
if (isset($orderByField) && is_array($orderByField) && count($orderByField) > 0) { | ||
foreach ($orderByField as $field) { | ||
$db->orderBy($table . '.' . $field['field_name'], $field['order_value']); | ||
if ( | ||
($tmpTable !== null && $tmpField !== null) && | ||
$field['field_name'] === $tmpField && | ||
$this->getSchema()->hasColumn($tmpTable, $tmpField) | ||
) { | ||
$db->orderBy($tmpTable . '.' . $tmpField, $field['order_value']); | ||
} else { | ||
$db->orderBy($table . '.' . $field['field_name'], $field['order_value']); | ||
} | ||
} | ||
} elseif (mb_strtolower($defaultField) === 'random') { | ||
} elseif (strtolower($defaultField) === 'random') { | ||
$db->inRandomOrder(); | ||
} else { | ||
$db->orderByDesc($table . '.' . $defaultField); | ||
if ( | ||
($tmpTable !== null && $tmpField !== null) && | ||
$defaultField === $tmpField && | ||
$this->getSchema()->hasColumn($tmpTable, $tmpField) | ||
) { | ||
$db->orderByDesc($tmpTable . '.' . $tmpField); | ||
} else { | ||
$db->orderByDesc($table . '.' . $defaultField); | ||
} | ||
} | ||
|
||
return $db; | ||
|
@@ -808,21 +832,36 @@ public function bindOrderBy(Builder $db, $orderByField, string $defaultField = ' | |
* | ||
* @param \Illuminate\Database\Query\Builder $db | ||
* @param $orderByField | ||
* @param mixed $table | ||
* @param $table | ||
* @param $tmpTable | ||
* @param $tmpField | ||
* | ||
* @return \Illuminate\Database\Query\Builder | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 07/02/2023 28:41 | ||
*/ | ||
public function bindOrderByNoDefault(Builder $db, $orderByField, $table = null): Builder | ||
{ | ||
public function bindOrderByNoDefault( | ||
Builder $db, | ||
$orderByField, | ||
$table = null, | ||
$tmpTable = null, | ||
$tmpField = null | ||
) { | ||
if (empty($table)) { | ||
$table = $this->table; | ||
} | ||
if (isset($orderByField) && is_array($orderByField) && count($orderByField) > 0) { | ||
foreach ($orderByField as $field) { | ||
$db->orderBy($table . '.' . $field['field_name'], $field['order_value']); | ||
if ( | ||
($tmpTable !== null && $tmpField !== null) && | ||
$field['field_name'] === $tmpField && | ||
$this->getSchema()->hasColumn($tmpTable, $tmpField) | ||
) { | ||
$db->orderBy($tmpTable . '.' . $tmpField, $field['order_value']); | ||
} else { | ||
$db->orderBy($table . '.' . $field['field_name'], $field['order_value']); | ||
} | ||
} | ||
} | ||
|
||
|